JS时刻:弃用警告:时刻build设回落到jsdate。 这是沮丧,将在即将到来的主要版本中删除
我得到的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.com/moment/moment/issues/1407 for more info.
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.com/moment/moment/issues/1407 for more info.
但我是一个新手,我不知道如何解决这个问题,所以上述消息消失。 我认为问题在于这两条线,但我不确定。
var nextMonth = moment(moment(year + "-" + month + "-1")).add(1, "months").format("MM"); var nextYear = moment(moment(year + "-" + month + "-1")).add(1, "months").format("YYYY");
我已经检查https://github.com/moment/moment/issues/1407和弃用警告:时刻build设回落到jsdate,但似乎都不能解决我的问题。
我想知道在这个计算中,我应该告诉格式到什么时候,或者至less如何以正确的格式进行计算,这样警告就消失了。
提前致谢!
其实我find了问题。
只需在两个计算中添加新的Date(),就可以再次进行标准化。
var nextMonth = moment(new Date(year, month - 1, 1)).add(1, "months").format("MM"); var nextYear = moment(new Date(year, month - 1, 1)).add(1, "months").format("YYYY");
我希望它能帮助别人!