
直接上代码
<el-date-pickerv-model="fillingList.declareDate"type="month":disabled="isDisplayName"placeholder="选择填报时间"value-format="yyyy-MM":picker-options="pickerOptions"@change="declareDateChange">
</el-date-picker>
data里面的数据
data(){return {pickerOptions: this.getStartStopMonth(),StartStopMonthArr: ['2023-05', '2023-02'],startTime: '2023-02',}
},
methods:{getStartStopMonth() {let that = thisreturn {disabledDate: (time) => {let nowYear = new Date().getFullYear();let nowMonth = new Date().getMonth() + 1;let nowYM = nowYear + '-' + (nowMonth >= 10 ? nowMonth : ('0' + nowMonth));let timeM = time.getMonth() + 1;let timeYM = time.getFullYear() + '-' + (timeM >= 10 ? timeM : ('0' + timeM));return timeYM > nowYM || that.StartStopMonthArr.includes(timeYM) || timeYM < that.startTime}}}
}