展示效果
解决方法
<el-form :model="queryParams" ref="queryForm" :inline="true" label-width="80px">
<el-form-item label="开始时间" prop="startTime">
<el-date-picker clearable size="small"
v-model="queryParams.startTime"
type="date"
value-format="yyyy-MM-dd"
placeholder="选择开始时间"
:picker-options="startNoTime">
</el-date-picker>
</el-form-item>
<el-form-item label="结束时间" prop="endTime">
<el-date-picker clearable size="small"
v-model="queryParams.endTime"
type="date"
value-format="yyyy-MM-dd"
placeholder="选择结束时间"
:picker-options="endNoTime">
</el-date-picker>
</el-form-item>
</el-form>
data() {
return {
queryParams: {
pageNum: 1,
pageSize: 10,
startTime: null,
endTime: null,
},
startNoTime: {
disabledDate(date) {
return date.getTime() > Date.now()
}
},
endNoTime: {
disabledDate(date) {
return date.getTime() > Date.now()
}
},
}
},
watch: {
"queryParams.startTime": {
handler(val) {
this.endNoTime = {
disabledDate(time) {
const time1 = new Date(val).getTime() - 8.64e7;
return time.getTime() < time1 || time.getTime() > Date.now()
}
}
}
},
"queryParams.endTime": {
handler(val) {
this.startNoTime = {
disabledDate(time) {
const time1 = new Date(val).getTime() - 8.64e7;
return time.getTime() > time1 || time.getTime() > Date.now()
}
}
}
},
},