美文网首页
ant-design vue range-picker 禁用当前

ant-design vue range-picker 禁用当前

作者: Rose_yang | 来源:发表于2020-05-27 18:29 被阅读0次
  <a-range-picker
                    :disabled-date="disabledDate"
                    :disabled-time="disabledRangeTime"
                    :show-time="{
                    hideDisabledOptions: true,
                    defaultValue: [moment('00:00:00', 'HH:mm:ss'), moment('11:59:59', 'HH:mm:ss')]
                  }"
                    format="YYYY-MM-DD HH:mm:ss"
                  />

  range (start, end) {
      const result = []
      for (let i = start; i < end; i++) {
        result.push(i)
      }
      return result
    },
    disabledDate (current) {
      return current < moment().startOf('day')
    },
    disabledRangeTime (_, type) {
      // 禁用当前时间之前的
      if (type === 'start') {
        return {
          disabledHours: () => this.range(0, moment().hour()),
          disabledMinutes: () => this.range(0, moment().minute()),
          disabledSeconds: () => this.range(0, moment().second())
        }
      }
      return {
        // disabledHours: () => [],
        // disabledMinutes: () => [],
        // disabledSeconds: () => []
      }
    },

相关文章

网友评论

      本文标题:ant-design vue range-picker 禁用当前

      本文链接:https://www.haomeiwen.com/subject/vmrgahtx.html