1、只能选择当前月份的
pickerOptions: { //大于当前月分的日期不可选
disabledDate: (time) => {
var date = new Date();
var year = date.getFullYear();
var month = date.getMonth() + 1;
if (month >= 1 && month <= 9) {
month = “0” + month;
}
var currentdate = year.toString() + month.toString();
var timeyear = time.getFullYear();
var timemonth = time.getMonth() + 1;
if (timemonth >= 1 && timemonth <= 9) {
timemonth = "0" + timemonth;
}
var timedate = timeyear.toString() + timemonth.toString();
return currentdate != timedate;
}
},
2.只能选择一个月区间的
times:’’,
pickerOptions: {
onPick: ({maxDate, minDate}) => {
this.times= minDate.getTime();
if (maxDate) {
this.times= ‘’
}
}, disabledDate: (time) => {
if (this.times!== ‘’) {
const one = 30 * 24 * 3600 * 1000;
const minTime = this.times- one;
const maxTime = this.times+ one;
return time.getTime() < minTime || time.getTime() > maxTime
}
}
}
3、只能选当天日期之前的
pickerOptions: {
disabledDate:(time)=>{
return time<new Date().now()
}
}