antd DatePicker DisabledDate 怎么自定义可选范围 在一个闭区间呢 比如说过去的一个月?

怎么自定义可选范围 在一个闭区间呢 比如说过去的一个月? (满足endDate 大于 startDate 肯定是必须的)

需要满足上述的条件肯定是要disableDate 方法每次都要满足两个条件

  disabledEndDate = (current) => {
    const startDate = this.state.startDate;
    if (!current || !startDate) {
      return false;
    }
    return current.valueOf() < startDate.valueOf();
  }

return的 结果中使用&& 无效 无法满足使可选取范围即大于一个时间点, 又小于一个时间点

求指导!

阅读 11k
4 个回答

return 中把 && 变成 || 即可

import moment from 'moment'

return current.valueOf() < moment(this.state.startDate).valueOf() || current.valueOf() > moment(this.state.endDate).valueOf() || current.valueOf() === moment(this.state.amazingDate).valueOf()

========================================================
开始之前日期禁用,结束之后日期禁用,并且禁用了开始到结束日期中的某一天

disabledEndDate+ disabledStartDate

新手上路,请多包涵

这个问题解决了吗?我也遇到这个问题了

新手上路,请多包涵

[

            moment()
              .month(moment().month() - 1)
              .startOf('month'),
            moment()
              .month(moment().month() - 1)
              .endOf('month'),
          ]
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题