element picker 时间控件,指定区间和指定月份置灰

element picker 时间控件,指定区间和指定月份置灰_第1张图片

直接上代码



data里面的数据

data(){
	return {
		pickerOptions: this.getStartStopMonth(),
		StartStopMonthArr: ['2023-05', '2023-02'],
		startTime: '2023-02',
	}
},
methods:{
	getStartStopMonth() {
		let that = this
		return {
			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
			}
		}
	}
}

你可能感兴趣的:(elementui)