a-range-picker控制禁止选择的时间

          <a-form-model-item label="时间周期"
                             prop="dateRange"
          >
            <a-range-picker
              v-model="form.dateRange"
              format="YYYY-MM-DD"
              value-format="YYYY-MM-DD"
              :disabled-date="disabledHDate"
              @change="onChange"
              @calendarChange="calendarChange"
            />
          </a-form-model-item>
// 导出数据时间周期间隔不允许超过90天,不允许选择2022-08-19之前的时间
disabledHDate(current) {
      if (this.form.dateRange && this.form.dateRange[0]) {
        return (
          current < moment(this.form.dateRange[0]).subtract(89, 'days') ||
          current > moment(this.form.dateRange[0]).add(89, 'days') ||
           current < moment('2022-08-19')
        )
      } else {
        return current < moment('2022-08-17')
      }
    },
    onChange(dateString) {
      this.startDate = dateString[0]
      this.endDate = dateString[1]
    },
    calendarChange(dates) {
      this.form.dateRange = dates
    },
 

 

posted on 2023-01-06 16:41  稳住别慌  阅读(940)  评论(0编辑  收藏  举报