//1.只能选择今天之后的日期
data (){
return {
pickerOptions: {
disabledDate(time) {
return time.getTime() < Date.now();
}
},
}
}
//2、开始日期不得选择早于今天
pickerOptions:{ //写在data函数里
disabledDate:time =>{
return time.getTime() < Date.now() - 8.64e7;
}
},
:picker-options="pickerOptions" //绑定在组件里面
//3、只能选择今天以及以前的日期
pickerOptions: {
disabledDate(time) {
return time.getTime() > Date.now() - 8.64e6
}
},
//4.只能选择今天之前的日期
data (){
return {
pickerOptions0: {
disabledDate(time) {
return time.getTime() > Date.now();
}
},
}
}
//5.设置选择三个月之前到今天的日期
data (){
return {
pickerOptions0: {
disabledDate(time) {
let curDate = (new Date()).getTime();
let three = 90 * 24 * 3600 * 1000;
let threeMonths = curDate - three;
return time.getTime() > Date.now() || time.getTime() < threeMonths;;
}
},
}
}
Vue使用ElementUI的DateTimePicker的时间限制选择范围
最新推荐文章于 2024-01-23 20:01:31 发布