element el-date-picker 开始时间小于结束时

2023-02-27  本文已影响0人  冰落寞成
<el-date-picker
        v-model="filterParames.startTime"
        type="datetime"
        placeholder="选择开始时间"
        :picker-options="pickerOptionsStart"
        >
        </el-date-picker>
      </div>
      <div class="bottom-item">
        <div class="item-label">结束时间</div>
        <el-date-picker
          v-model="filterParames.endTime"
          type="datetime"
          placeholder="选择结束时间"
          :picker-options="pickerOptionsEnd">
        </el-date-picker>
data () {
    return {
      filterParames: {
        keyWord: null, // 关键字
        startTime: new Date(), // 开始时间
        endTime: new Date(), // 结束时间
        status: 1
      },
     pickerOptionsStart: {
        disabledDate: time => {
          if (this.filterParames.endTime) {
            return time.getTime() > new Date(this.filterParames.endTime).getTime()
          }
        }
      },
      pickerOptionsEnd: {
        disabledDate: time => {
          if (this.filterParames.startTime) {
            return time.getTime() < new Date(this.filterParames.startTime).getTime() - 24 * 60 * 60 * 1000
          }
        }
      }
    }
上一篇下一篇

猜你喜欢

热点阅读