雅虎为JavaScript开源了一套不错的国际化工具,他们称之为FormatJS。
FormatJS指南提到日期随默认格式short、medium、long和full而来。
FormatJS为尘埃、车把和反应提供集成。
当在npm管理的环境中使用React (React-Intl)时,我似乎不能格式化数字。
从我的部分,我打电话给
this.formatDate(this.props.guide.get('date'), 'short')但是,我得到了以下错误:
未定义的ReferenceError:没有日期格式命名:未定义
我的约会被定义为“短”,这应该是内置的。怎么回事?
发布于 2014-11-21 13:44:57
您可以使用:
{this.formatDate(this.props.guide.get('date'), {
day : 'numeric',
month: 'long',
year : 'numeric'
})}“短”不是内置的。它在FormatJS指南中的Render选项卡中被删除如下:
var intlData = {
"locales": "en-US",
"formats": {
"date": {
"short": {
"day": "numeric",
"month": "long",
"year": "numeric"
}
}
}https://stackoverflow.com/questions/27010990
复制相似问题