element-ui 날짜 선택기 선택 범위 제한

5055 단어 element-ui
  • 당일 또는 이전 날짜만 선택 가능
  • // 
    <el-date-picker type="date" value-format="timestamp" v-model="form.birthDate" placeholder=" " class="display-block" :picker-options="pickerBeginDateBefore"></el-date-picker>
    // data 
    pickerBeginDateBefore: {
            disabledDate: time => {
              let _now = Date.now();
                return time.getTime() > _now;
            }
          },
  • 선택한 시간대 사이의 범위
  •             <el-form-item label=" " class="inline">
                  <el-date-picker value-format="timestamp" v-model="params.startDate" type="date" :picker-options="pickerBeginDateBefore" placeholder=" ">
                  </el-date-picker>
                  <span class="item-font"> </span>
                  <el-date-picker value-format="timestamp" v-model="params.endDate" type="date" :picker-options="pickerBeginDateAfter" placeholder=" ">
                  </el-date-picker>
                </el-form-item>
    //data 
          pickerBeginDateBefore: {
            disabledDate: time => {
              let beginDateVal = this.params.endDate;
              if (beginDateVal) {
                return time.getTime() > beginDateVal;
              }
            }
          },
          pickerBeginDateAfter: {
            disabledDate: time => {
              let beginDateVal = this.params.startDate;
              if (beginDateVal) {
                return time.getTime() < beginDateVal;
              }
            }
          },

    좋은 웹페이지 즐겨찾기