momentjs Deprecation Warning
Moment.js运行时,刷新页面后出现Moment Deprecation Warning
用moment对象代替Date()对象,用toDate()转换成Date()对象,还是继续有错误
报错信息如下
Deprecation warning: dates accessor is deprecated. Use date instead.
Arguments:
Error
at Moment.dates (/Users/ephraimguo/Documents/OST_work/booking_Prototype/node_modules/moment/moment.js:320:98)
at eval (eval at compile (/Users/ephraimguo/Documents/OST_work/booking_Prototype/node_modules/ejs/lib/ejs.js:549:12), <anonymous>:61:39)
at returnedFn (/Users/ephraimguo/Documents/OST_work/booking_Prototype/node_modules/ejs/lib/ejs.js:580:17)
at tryHandleCache (/Users/ephraimguo/Documents/OST_work/booking_Prototype/node_modules/ejs/lib/ejs.js:223:34)
at View.exports.renderFile [as engine] (/Users/ephraimguo/Documents/OST_work/booking_Prototype/node_modules/ejs/lib/ejs.js:437:10)
at View.render (/Users/ephraimguo/Documents/OST_work/booking_Prototype/node_modules/express/lib/view.js:135:8)
at tryRender (/Users/ephraimguo/Documents/OST_work/booking_Prototype/node_modules/express/lib/application.js:640:10)
at Function.render (/Users/ephraimguo/Documents/OST_work/booking_Prototype/node_modules/express/lib/application.js:592:3)
at ServerResponse.render (/Users/ephraimguo/Documents/OST_work/booking_Prototype/node_modules/express/lib/response.js:1008:7)
at /Users/ephraimguo/Documents/OST_work/booking_Prototype/routes/index.js:248:18
at Layer.handle [as handle_request] (/Users/ephraimguo/Documents/OST_work/booking_Prototype/node_modules/express/lib/router/layer.js:95:5)
at next (/Users/ephraimguo/Documents/OST_work/booking_Prototype/node_modules/express/lib/router/route.js:137:13)
at Route.dispatch (/Users/ephraimguo/Documents/OST_work/booking_Prototype/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/Users/ephraimguo/Documents/OST_work/booking_Prototype/node_modules/express/lib/router/layer.js:95:5)
at /Users/ephraimguo/Documents/OST_work/booking_Prototype/node_modules/express/lib/router/index.js:281:22
at Function.process_params (/Users/ephraimguo/Documents/OST_work/booking_Prototype/node_modules/express/lib/router/index.js:335:12)
这样问题应该如何处理。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
答案很明显:你用的moment库旧了,使用了一个过时方法
moment().dates
,最新是用moment().date
。(2.16之前的版本)解决方式: 升级Moment库到最新版(目前2.22.2)
至于怎么升级,修改一下项目根目录下的package.json,找到其中的moment,换上最新版本号