<el-date-picker v-model="startMonth"
clearable
:clearable="false"
value-format="yyyy-MM"
type="month"
:picker-options="startDateOptions"
placeholder="请选择开始月份"
style="margin-left: 10px;"></el-date-picker>
<el-date-picker v-model="endMonth"
clearable
:clearable="false"
value-format="yyyy-MM"
type="month"
:picker-options="EndDateOptions"
placeholder="请选择结束月份"
style="margin-left: 10px;"></el-date-picker>
startDateOptions: {
disabledDate: (time) => {
let endDateVal = this.endMonth;
if (endDateVal) {
let one = 30 * 24 * 3600 * 1000 * 12;
return (
time.getTime() > new Date(endDateVal).getTime() ||
time.getTime() < new Date(endDateVal).getTime() - one
);
}
}
},
endDateOptions: {
disabledDate: (time) => {
let beginDateVal = this.startMonth;
if (beginDateVal) {
let one = 30 * 25 * 3600 * 1000 * 12;
return (
time.getTime() < new Date(beginDateVal).getTime() ||
time.getTime() > new Date(beginDateVal).getTime() + one ||
time.getTime() > Date.now()
);
}
}
},