element DateTimePicker 结束时间不能小于开始时间(开始时间不能小于当前时间)

html



        
        




        

data:

startTime: '',
endTime: '',
//限制开始时间
pickerOptionsStart: {
    disabledDate(time) {
        return time.getTime() < new Date(new Date().toLocaleDateString()).getTime();
     }
},
pickerOptionsEnd: {},

js:

      //结束时间限制开始时间
      changeStart() {

        this.pickerOptionsStart = Object.assign({}, this.pickerOptionsStart, {
          // 可通过箭头函数的方式访问到this
          disabledDate: (time) => {

            var times = '';

            times = this.endTime < time.getTime() || time.getTime() < new Date(new Date().toLocaleDateString())
              .getTime();

            return times
          }
        })

      },
      //开始时间 控制结束时间   
      changeEnd() {

        this.pickerOptionsEnd = Object.assign({}, this.pickerOptionsEnd, {
          disabledDate: (time) => {

            return time.getTime() < this.startTime
          }
        })
      },

 

你可能感兴趣的:(js,vue)