当月之后 不含当月
methods: {
getTime() {
return {
disabledDate(time) {
const date = new Date();
const year = date.getFullYear();
let month = date.getMonth() + 1;
if (month >= 1 && month <= 9) {
month = "0" + month;
}
const currentdate = year.toString() + month.toString();
const timeyear = time.getFullYear();
let timemonth = time.getMonth() + 1;
if (timemonth >= 1 && timemonth <= 9) {
timemonth = "0" + timemonth;
}
const timedate = timeyear.toString() + timemonth.toString();
return currentdate <= timedate;
},
};
},
}
当天等时间
data() {
return {
// 设置可选择的时间段,*** 必须在 data 返回数据 ***
setDateRange: {
disabledDate: time => {
// 只能选择当前 1 年内的时间
const year = 365 * 24 * 3600 * 1000;
// 只能选择当前 1 月的时间
const month = 30 * 24 * 3600 * 1000;
// 只能选择当前 1 周的时间
const week = 7 * 24 * 3600 * 1000;
// 返回小于当前日期并近【1年】【1月】【1周】内的日期
// 注意:这是从当前日期开始往前算,如果当前日期可选的话,不要写【-8.64e7】
return time.getTime() > Date.now() || time.getTime() < (Date.now() - 8.64e7) - year;
// 禁用今天之前的日期【当前天可选】
return time.getTime() < Date.now() - 8.64e7;
// 禁用今天之前的日期【当前天不可选】
return time.getTime() < Date.now();
// 禁用今天之后的日期【当前天不可选】
return time.getTime() > Date.now() - 8.64e7;
// 禁用今天之后的日期【当前天可选】
return time.getTime() > Date.now();
}
},
}
}