The el-date-picker component implements specific date disabling (for example: only the current date (inclusive) and later dates can be selected).

  1. Disable dates before the current date (only select from today to after today):

<el-date-picker
              type="date"
              placeholder="请选择时间"
              :picker-options="pickerOptions"
              v-model="ruleForm.date"
              :clearable="false"
            ></el-date-picker>



pickerOptions: {
            // 限制预约时间
            disabledDate(time) {
              return time.getTime() < Date.now() - 24 * 60 * 60 * 1000
            }
         },

2. You can only select the date range from today to a certain time period in the future (here, take 3 months and 90 days as an example):

<el-date-picker
                  type="date"
                  v-model="ruleForm.date2"
                  :picker-options="pickerOptions2"
                  placeholder="请选择完成日期"
                  :clearable="false"
                ></el-date-picker>



pickerOptions2: {
            // 限制预约时间
            disabledDate(time) {
              return (time.getTime() < Date.now() - 24 * 60 * 60 * 1000) || (time.getTime() > Date.now() + 90 * 24 * 60 * 60 * 1000)
            }
         },

Guess you like

Origin blog.csdn.net/Yi2008yi/article/details/122231271