【发布时间】:2019-06-27 02:28:55
【问题描述】:
我已经缩小范围,发现只有当我尝试传递<Moment /> 组件时才会发生错误,如React-Moment documentation 中所述。到目前为止,我还没有找到任何特定于这个包的解释,希望有人遇到过类似的问题!
文档说明了这样的用法:
import Moment from 'react-moment';
// then within the class component:
return (
const dateToFormat = '1976-04-19T12:59-0500';
<Moment>{dateToFormat}</Moment>
);
我想采用这样的原始日期字符串:
<Text>Created {this.props.postDate}</Text>
这样存储的:"postDate": "2019-01-31T04:13:31.224Z"
但到目前为止,无论何时我添加 <Moment>{this.props.postDate}</Moment>,无论是在现有 <Text /> 块的外部还是内部,我都会变红:
【问题讨论】:
标签: react-native momentjs