admin管理员组文章数量:1602099
参考资料: stackoverflow Joe Wilson的回答
问题
在 Jade
中使用 moment
格式化时间时,报出这个警告。
Deprecation warning: moment construction falls back to js Date. This is discouraged and will be removed in upcoming major release. Please refer to https://github/moment/moment/issues/1407 for more info.
解决方法
moment()
传入ISO
标准格式的时间字符串:
moment(‘2014-04-23T09:54:51’);
- 附加参数告诉
moment
这个时间字符串的格式:
moment(‘Wed, 23 Apr 2014 09:54:51 +0000’, ‘ddd, DD MMM YYYY HH:mm:ss ZZ’);
- 将时间字符串转换为一个 JavaScript 的
Date
对象,在传入moment
:
moment(new Date(‘Wed, 23 Apr 2014 09:54:51 +0000’));
附加
js 中,生成 ISO 标准格式时间字符串方法
var isotime = new Date().toISOString();
本文标签: 解决方法deprecationwarningMomentjs
版权声明:本文标题:Moment.js遇到Deprecation warning: moment construction falls back to js Date 解决方法 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/dianzi/1728396635a1157083.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论