element el-date-picker Date TimePicker 联动最多选择15天的时间

一、使用Date TimePicker

 二、定义变量

 data () {
   return {
     selectDate: '',
     defaultTime: ['00:00:00', '23:59:59'],
     
     timeRange: [],
    pickerOptions: {
       onPick: ({ maxDate, minDate }) => {
         this.selectDate = minDate.getTime()
         if (maxDate) {
           this.selectDate = ''
         }
       },
       disabledDate: (time) => {
         if (this.selectDate !== '') {
           const one = (15 * 24 * 3600 - 1) * 1000 // 00:00:00 到23:59:59
           const minTime = this.selectDate - one
           const maxTime = this.selectDate + one
           return time.getTime() < minTime || time.getTime() > maxTime
         }
       }
     }
}
}

 

你可能感兴趣的:(vue.js,javascript,前端)