首先在时间选择器中定义 :picker-options=“pickerOptions”
<el-date-picker range-separator="至" start-placeholder="开始日期" endplaceholder="结束日期" :picker-options="pickerOptions"></el-date-picker>
在computed 中写入:
我这边是根据time_space的值来判断到底是什么样的范围
computed:{
pickerOptions() {
return {
disabledDate:time=>{
if(that.time_space==1){
return new Date(that.endTime).getTime() < time.getTime()|| new Date(that.startTime).getTime() > time.getTime()
}
if(that.time_space==2){
return new Date(that.startTime).getTime() < time.getTime()
}
}
};
}
},
如果还看不懂,那动手试一试哦~,会有不一样的收获!加油!