element UI 日历选择规则

75 阅读1分钟
pickerOptions: {        onPick: ({ maxDate, minDate }) => {          // 选中的时间          this.choiceDate0 = minDate.getTime();          if (maxDate) {            this.choiceDate0 = "";          }        },        disabledDate: (time) => {          // 选中时间的Date          let choiceDateTime = new Date(this.choiceDate0).getTime();          // 一年前的日期          const minTime = new Date(choiceDateTime).setMonth(            new Date(choiceDateTime).getMonth() - 12          );          // 一年后的日期          const maxTime = new Date(choiceDateTime).setMonth(            new Date(choiceDateTime).getMonth() + 11          );          const min = minTime;          const max = maxTime;          // 有选择时间时          if (this.choiceDate0) {            // 大于选择第一时间下个月的时间不可选,大于今天不可选            if (time.getTime() > max ) {              return true            }            if (time.getTime() < min ) {              return true;            }          }          const lastMone = new Date().setMonth(            new Date().getMonth() - 1          );          return time.getTime() > lastMone;        }      },