elementui实现DatePicker日期选择器年月限制

效果图片

elementui实现DatePicker日期选择器年月限制_第1张图片

elementui实现DatePicker日期选择器年月限制_第2张图片

代码





curDate: "",
pickerOptions: {
    onPick: ({ maxDate, minDate }) => {
        this.curDate = minDate.getTime();
        if (maxDate) {
            this.curDate = "";
        }
    },
    disabledDate: (time) => {
            let oldDate = new Date('2021-12-31T12:00:00.000Z') #最小日期
            let oneYear = new Date(oldDate).getTime(); 
            return (
                time.getTime() > Date.now() ||
                time.getTime() < oneYear
            );
    },
},
value1: "",

你可能感兴趣的:(前端,vue.js)