界面代码:
<el-col :span="8">
<el-form-item label="开始日期" class="form-row-space">
<el-date-picker :picker-options="pickerOptionsStart" v-model="editDeviceGroup.start_date" type="date" placeholder="选择日期时间"></el-date-picker>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="结束日期" class="form-row-space">
<el-date-picker :picker-options="pickerOptionsEnd" v-model="editDeviceGroup.end_date" type="date" placeholder="选择日期时间"></el-date-picker>
</el-form-item>
</el-col>
前端代码:
return {
pickerOptionsStart: {
disabledDate: time => {
let endDateVal = this.editDeviceGroup.end_date;
if (endDateVal) {
return time.getTime() > new Date(endDateVal).getTime();
}
}
},
pickerOptionsEnd: {
disabledDate: time => {
let beginDateVal = this.editDeviceGroup.start_date;
if (beginDateVal) {
return (
time.getTime() <
new Date(beginDateVal).getTime() - (1 * 24 * 60 * 60 * 1000)+1
);
}
}
},
}
原文地址:https://www.cnblogs.com/chengyihardworking/p/10102875.html