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

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


重点::picker-options="expireTimeOPtion"

1.只能选今天或者今天之后的时间

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

2.今天以及今天之前的日期


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

3.只能选取今天往后三天内

data() {
  return {
   expireTimeOPtime: {
        disabledDate(time) {
          const times = new Date(new Date().toLocaleDateString()).getTime() + 3 * 8.64e7 - 1
          return time.getTime() < Date.now() - 8.64e7 || time.getTime() > times// 如果没有后面的-8.64e7就是不可以选择今天的
        }
      }
  }
}
 

重点:这句代码是写在data里面的,不是methods里的

 

你可能感兴趣的:(Element,UI,vue.js,elementui)