[antdv: DatePicker] `value` provides invalidate moment time. If you want set empty value,use `null`
Ant Design Vue DatePicker 报错warning.js?2149:7 Warning: [antdv: DatePicker] `value` provides invalidate moment time. If you want to set empty value, use `null` instead.操作,点击编辑时候,使用v-decorator的initialVa
·
Ant Design Vue DatePicker 报错
warning.js?2149:7 Warning: [antdv: DatePicker] `value` provides invalidate moment time. If you want to set empty value, use `null` instead.
操作,点击编辑时候,使用v-decorator的initialValue方法赋值报错
原代码
<a-date-picker style="width: 100%" :placeholder="$t('user.check.serviceExpirationTime')" v-decorator="['serviceExpirationTime', {initialValue:!this.model.serviceExpirationTime?null:moment(this.model.serviceExpirationTime).format(this.dateFormat)}]"
:getCalendarContainer="node => node.parentNode" :disabled="disableSubmit" />
这里通过moment.format后的时间是一个string类型,而ant design vue datepicker 默认是个moment 所以会报错
解决方法
初始化日期的时候,一定要设置为一个moment类型的
<a-date-picker style="width: 100%" :placeholder="$t('user.check.serviceExpirationTime')" v-decorator="['serviceExpirationTime', {initialValue:!this.model.serviceExpirationTime?null:moment(moment(this.model.serviceExpirationTime).format(this.dateFormat))}]"
:getCalendarContainer="node => node.parentNode" :disabled="disableSubmit" />
更多推荐
已为社区贡献3条内容
所有评论(0)