el-date-picker コンポーネントは、特定の日付の無効化を実装します (たとえば、現在の日付 (包括的) 以降の日付のみを選択できます)。

  1. 現在の日付より前の日付を無効にします (今日から今日以降のみを選択します)。

<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. 日付範囲は、今日から将来の特定の期間までのみ選択できます (ここでは、例として 3 か月と 90 日を使用します)。

<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)
            }
         },

おすすめ

転載: blog.csdn.net/Yi2008yi/article/details/122231271