element ui 日期控件 范围时间限制 记录

时间:2020-11-29 18:09:57
  <el-date-picker
:clearable="false"
:picker-options="pickerOptions0"
value-format="yyyy-MM-dd"
v-model="startTime"
type="date"
placeholder="选择日期">
</el-date-picker>

<el-date-picker
:clearable="false"
:picker-options="pickerOptions1"
value-format="yyyy-MM-dd"
v-model="endTime"
type="date"
placeholder="选择日期">
</el-date-picker>
//开始时间小于等于今天可选
pickerOptions0: {
disabledDate(time) {
return time.getTime() < Date.now() - 8.64e7;
}
},
//结束时间小于等于开始时间可选 - 8.64e7
pickerOptions1: {
disabledDate: (time) => {
return time.getTime() < Date.now() - 8.64e7 ||
time.getTime() < new Date(that.value1).getTime()- 8.64e7;
}
},