Element UI 日期范围选择器限制只能选今天之前的时间,或者只能选今天之后的时间

<el-date-picker
    v-model="value"
    type="daterange"
    range-separator="至"
    placeholder="选择日期"
    start-placeholder="开始日期"
    end-placeholder="结束日期"
    :picker-options="pickerOptions"
>
</el-date-picker>

今天以及今天之后的日期

data() {
  return {
    pickerOptions: {
      disabledDate(time) {
        return time.getTime() < Date.now() - 8.64e7;  //如果没有后面的-8.64e7就是不可以选择今天的 
      }
    },
  }
}

 今天以及今天以前的日期

data() {
  return {
    pickerOptions: {
      disabledDate(time) {
        return time.getTime() > Date.now() - 8.64e6;  //如果没有后面的-8.64e6就是不可以选择今天的 
      }
    },
  }
}

 

https://blog.csdn.net/qq_33769914/article/details/83856268

猜你喜欢

转载自blog.csdn.net/GrootBaby/article/details/107315462