ReactJS Ant Design - 在 DatePicker 中禁用小于任何默认日期的日期 [英] ReactJS Ant Design - Disable dates less than any default date in DatePicker

查看:22
本文介绍了ReactJS Ant Design - 在 DatePicker 中禁用小于任何默认日期的日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在处理 antd 框架时,我正在尝试禁用 DatePicker 小于给定 defaultDate 的日期,我无论如何都无法正确处理.情况是说日期选择器的 defaultDate 是 2028-12-20 所有日期都应在此以下禁用..

Working on antd framework, I am trying to disable the DatePicker date which are less than given defaultDate, I am not able to get it right by any means. The situation is say defaultDate of the Date Picker is 2028-12-20 all dates should be disabled below this..

执行此操作的回调如下

disabledDate = (current) => {
    return current && current < moment().endOf('day');;
}

where current = defaultDate 已提供它不会改变,我不知道如何做到这一点..

where current = defaultDate which has been provided it doesn't change, I am not sure how to do this..

我在这里

任何帮助将不胜感激.

谢谢.

推荐答案

可以通过以下方式完成:

It can be done in following way:

disabledDate(current) {
  let customDate = "2018-11-25";
  return current && current < moment(customDate, "YYYY-MM-DD");
}

这是工作演示

这篇关于ReactJS Ant Design - 在 DatePicker 中禁用小于任何默认日期的日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆