element-ui 日期组件选择只能在三个月内
step1
参考element ui提供的一些方法
step2
data >> return写入
duration
,定义为数组
注意:这里的this
指向已改变,需在return
上方let _this = this;
pickerOptions:{
disabledDate(time){
let currentTime=_this.duration[0]
let threeMonths=60*60*1000*24*90
if(currentTime){
return time.getTime() >currentTime.getTime() + threeMonths || time.getTime() < currentTime.getTime() - threeMonths
}
},
onPick({
minDate,maxDate}){
// 当第一时间选中才设置禁用
if(minDate && !maxDate){
_this.duration[0]=minDate
}
if(maxDate){
_this.duration[1]=maxDate
}
}
},
复制粘贴直接用就完事了,白给!