javascript - 从 webpack 导入后,Vue 应用程序中的 MomentJS 警告
问题描述
经过一段时间的搜索,我看到所有关于这个警告的帖子都是在使用 MomentJS 时引起的,但在我的情况下,这个警告是在我的 main.js 文件中导入后显示的,甚至没有第一次开始使用它,我什至还没有在我的代码的任何部分添加“新日期()”或任何时刻调用。
这是我收到的全部警告:
Deprecation warning: value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are discouraged and will be removed in an upcoming major release. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.
Arguments:
[0] _isAMomentObject: true, _isUTC: false, _useUTC: false, _l: undefined, _i: function Vue (options) {
if ("development" !== 'production' &&
!(this instanceof Vue)
) {
warn('Vue is a constructor and should be called with the `new` keyword');
}
this._init(options);
}, _f: undefined, _strict: undefined, _locale: [object Object]
Error
at Function.eval [as createFromInputFallback] (webpack-internal:///./node_modules/moment/moment.js:320:98)
at configFromInput (webpack-internal:///./node_modules/moment/moment.js:2606:19)
at prepareConfig (webpack-internal:///./node_modules/moment/moment.js:2577:13)
at createFromConfig (webpack-internal:///./node_modules/moment/moment.js:2544:44)
at createLocalOrUTC (webpack-internal:///./node_modules/moment/moment.js:2631:16)
at createLocal (webpack-internal:///./node_modules/moment/moment.js:2635:16)
at hooks (webpack-internal:///./node_modules/moment/moment.js:12:29)
at Function.Vue.use (webpack-internal:///./node_modules/vue/dist/vue.esm.js:4850:14)
at eval (webpack-internal:///./src/main.js:51:46)
at Object../src/main.js (http://localhost:8080/app.js:14037:1)
我在项目中添加 momentJS 的方式是运行:
npm i moment -D
然后在 main.js 我有以下内容:
import * as Moment from 'moment'
Vue.use(Moment)
window.app = new Vue({
el: '#app',
router: Router,
store: store,
render: h => h(App)
})
我知道这是一个警告,但在每次页面刷新时都有它有点烦人。最好避免它。
有什么线索吗?提前致谢。
解决方案
推荐阅读
- angular - 一个空数组被推送到 localStorage 而不是数据
- clojure - Clojure:将值设置为键
- javascript - 在 javascript 中将数组转换为对象,与 d3 输出相同
- java - 将代码从 Java 更改为 Kotlin 后注释未正确转换
- angular - 在双花括号内呈现 HTML
- android - Android View 的 measure 和 onMeasure 方法有什么区别?
- sql-server - 如何编写查询以循环分配和计算资金
- c - 程序返回错误的数字
- c++ - 在游戏引擎布局中使用 shared_ptr?
- r - 绘制 3D 平面和矢量