element-ui 日期组件选择只能在三个月内
1、2、pickerOptions: {disabledDate(time){let currentTime=that.duration[0]let threeMonths=60*60*1000*24*90if(currentTime){return .
·
1、
2、
pickerOptions: {
disabledDate(time){
let currentTime=that.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){
that.duration[0]=minDate
}
if(maxDate){
that.duration[1]=maxDate
}
},
shortcuts: [{
text: '最近一周',
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
picker.$emit('pick', [start, end]);
}
}, {
text: '最近一个月',
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
picker.$emit('pick', [start, end]);
}
}, {
text: '最近三个月',
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
picker.$emit('pick', [start, end]);
}
}],
},
更多推荐
已为社区贡献1条内容
所有评论(0)