<el-date-picker
v-model="value"
type="daterange"
align="right"
size="mini"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
value-format="yyyy-MM-dd"
@change="handlerChange">
</el-date-picker>
data() {
return {
value: [],
test: ['2023-10-19', '2023-10-25'] // 默认值
}
},
created() {
this.value = this.test
},
methods: {
handlerChange(val) {
// 需要在$nextTick进行赋值才能进行回显
this.$nextTick(() => {
if (!val) {
this.value = this.test
}
})
}
}