时间选择器限制只能选择30天 并且明天以后不可选

pickerOptions: {

        onPick: ({ maxDate, minDate}) => {

          this.minDate = minDate

        },

        disabledDate:

        (time) => {

          if (this.minDate) {

            return time > new Date(this.minDate).getTime() +  24 * 3600 * 1000 * 29 || time < new Date(this.minDate).getTime() -  24 * 3600 * 1000 * 29 || time > new Date(new Date().toLocaleDateString()).getTime()

          } else {

            return  time > new Date(new Date().toLocaleDateString()).getTime()

          }

        }

      }

时间选择器改变后同事要触发的事件

changeEvent (val) {

      this.pickerBeginDateBefore = {

        disabledDate: (time) => {

          if (this.minDate) {

            return (

              time > new Date(this.minDate.getTime() + 29 * 24 * 3600 * 1000) ||

              time < new Date(this.minDate.getTime() - 29 * 24 * 3600 * 1000)

            )

          }

          return time.getTime() > Date.now()

        }

      }

    },

上一篇:2021-11-23 elementUI 日期选择器怎么限制可选取的日期范围?


下一篇:Ocelot+Consul 集群搭建实践