Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.0k views
in Technique[技术] by (71.8m points)

iview datepicker type='daterange' 动态设置可选范围

当选择日期组件的开始时间以后,动态设置可选范围在一个月内,网上有通过.native来获取每次点击事件,但无法生效,事件只触发一次,选择时间的时候不触发了,有没有其他办法实现?
https://www.lanwuyaojiu.cn/bl...

<DatePicker ref="date" slot="extra"
          :value="time"
          :options="dateOption"
          @click.native="nativeClick"
          type="daterange"
          placement="bottom-end"
          placeholder="选择日期" style="width: 200px"></DatePicker>
    nativeClick() {
      const target = this.$refs['date'].$refs['pickerPanel']
      const { from, to } = target['rangeState']
      console.log(from, to)
      if (from && ! to) {
        this.dateOption = {
          disabledDate(value) {
            const startTime = new Date(from)
            const endTime = new Date(from)
            startTime.setDate(from.getDate() - 30)
            endTime.setDate(from.getDate() + 30)
            return !(value >= startTime && value <= endTime)
          }
        }
      } else {
        this.dateOption = {
          disabledDate() {
            return false
          }
        }
      }
    }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...