- 禁用当前日期之前的日期(只能选择今日到今日之后):
<el-date-picker
type="date"
placeholder="请选择时间"
:picker-options="pickerOptions"
v-model="ruleForm.date"
:clearable="false"
></el-date-picker>
pickerOptions: {
// 限制预约时间
disabledDate(time) {
return time.getTime() < Date.now() - 24 * 60 * 60 * 1000
}
},
2.只能选择今日到未来某时间段的日期范围(此处以3个月90天为例):
<el-date-picker
type="date"
v-model="ruleForm.date2"
:picker-options="pickerOptions2"
placeholder="请选择完成日期"
:clearable="false"
></el-date-picker>
pickerOptions2: {
// 限制预约时间
disabledDate(time) {
return (time.getTime() < Date.now() - 24 * 60 * 60 * 1000) || (time.getTime() > Date.now() + 90 * 24 * 60 * 60 * 1000)
}
},