el-data-picker限制日期可选范围
<el-date-picker
class="date"
v-model="date"
type="date"
@change="dateChange"
value-format="yyyy-MM-dd"
format="yyyy-MM-dd"
placeholder="选择日期"
:picker-options="datePickerOptions"
>
</el-date-picker>
data中
datePickerOptions: {
disabledDate: this.disabledDate,
},
method中
disabledDate(currentDate) {
return currentDate.getTime() > Date.now() || currentDate.getTime() < (Date.now() - this.dateRecord*24*60*60*1000);
},
这里的this.dateRecord可以是自己设定的值
表示今天往后的dateRecord天