datarange类型的el-data-picker动态限制日期跨度
<el-date-picker
value-format="yyyy-MM-dd"
v-model="dateRange"
size="small"
type="daterange"
:clearable='false'
:picker-options="daterangeOption"
start-placeholder="开始日期"
end-placeholder="结束日期">
</el-date-picker>
export default {
data () {
timeLim: null,
daterangeOption: {
disabledDate: (date) => {
let lastMonth = this.timeLim.getTime() - 31*3600*24*1000
let nextMonth = this.timeLim.getTime() + 31*3600*24*1000
return date.getTime() >= Date.now() || date.getTime() < lastMonth || date.getTime() > nextMonth;
},
onPick: (date) => {
if (date.maxDate === null) {
this.timeLim = date.minDate
} else {
this.timeLim = null
}
}
},
}
}