需要注意点: v-model 与 default-value 绑定值与默认值都必须是moment对象。否则控制台会报错
html部分
<div class="query-date left marginright">
<span class="textboxstyle">开始时间:</span>
<a-date-picker
v-model="startValue"
:disabled-date="disabledStartDate"
format="YYYY/MM/DD"
placeholder="开始日期"
:default-value="defaultstartValue"
ref="abc"
/>
</div>
<div class="query-date left marginright">
<span class="textboxstyle">结束时间:</span>
<a-date-picker
:default-value="defaultendValue"
v-model="endValue"
:disabled-date="disabledEndDate"
format="YYYY/MM/DD"
placeholder="结束日期"
ref="abc"
/>
</div>
引入moment
const start = new Date(new Date().getTime()-24*60*60*1000+1000)
const end = new Date()
import moment from 'moment'
data中数据
data() {
return {
dateFormat: 'YYYY/MM/DD',
defaultstartValue:moment(start, this.dateFormat),
defaultendValue:moment(end, this.dateFormat),
startValue: moment(start, this.dateFormat),
endValue: moment(end, this.dateFormat),
}
},
}