angular – 类型’Moment’不能指定为’Date’类型. ‘Moment’
发布时间:2020-12-17 06:49:04 所属栏目:安全 来源:网络整理
导读:我用angular2应用程序配置了一下,当我试图将本周星期六的日期分配给日期类型变量时, case "weekend": this.fromDate = moment().startOf('week'); 它显示错误说, Type 'Moment' is not assignable to type 'Date'. Property 'toDateString' is missing in ty
我用angular2应用程序配置了一下,当我试图将本周星期六的日期分配给日期类型变量时,
case "weekend": this.fromDate = moment().startOf('week'); 它显示错误说, Type 'Moment' is not assignable to type 'Date'. Property 'toDateString' is missing in type 'Moment' 我在我的组件中输入了以下内容, import * as moment from 'moment/moment'; 解决方法startOf :
所以它返回一个时刻对象.如果需要转换为JavaScript日期,请使用 case "weekend": this.fromDate = moment().startOf('week').toDate(); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐
热点阅读