Warning: [antdv: DatePicker] `value` provides invalidate moment time. If you want to set empty value
Posted 尔嵘
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Warning: [antdv: DatePicker] `value` provides invalidate moment time. If you want to set empty value相关的知识,希望对你有一定的参考价值。
vue-ant使用a-date-picker组件报错:
Warning: [antdv: DatePicker] `value` provides invalidate moment time. If you want to set empty value, use `null` instead.
原代码:
<a-form
layout ="inline"
v-model="dataForm"
>
<a-form-item label="日期:">
<a-date-picker
@change="handleSelectDateOther"
:clearable="false"
v-model="dataForm.selectDate2"
mode="date"
size="small"
style="width: 160px"
placeholder="选择日期"
:picker-options="pickerOptions"
></a-date-picker>
</a-form-item>
</a-form>
/*
*以下是js中定义
*/
data(){
return:{
dataForm: {
selectDate: this.$getCurrentTime(0), //自定义一个全局获取当前日期的函数
}
}
}
产生原因:很明显,上面data中定义的绑定日期变是一个字符类型,a-date-picker绑定的时间时间是一个string类型,而ant design vue datepicker 默认需要moment格式,所以会报错。
解决:
selectDate: moment(this.$getCurrentTime(0), 'YYYY-MM-DD'),
以上是关于Warning: [antdv: DatePicker] `value` provides invalidate moment time. If you want to set empty value的主要内容,如果未能解决你的问题,请参考以下文章
解决vue(antdv)报错: Warning: [antd: LocaleProvider] `LocaleProvider` is deprecated.
Warning: [antdv: LocaleProvider] `LocaleProvider` is deprecated. Please use `local
Warning: [antdv: LocaleProvider] `LocaleProvider` is deprecated. Please use `local