2023-03-14 antd 日期组件 禁用明天的日期,且今天要能选中

直接上代码:

<DatePicker
    showTime
    format="YYYY年MM月DD日 HH:mm"
    disabledDate={current => current && current > moment().endOf('second')}
/>

主要看这个:disabledDate={current => current && current > moment().endOf('second')}

endOf:以什么时间结尾(主要不要用startOf,它表示截取到当前指定时间区间的第一秒,而endOf为取到当前指定时间区间的最后一秒)。

看不懂上链接:http://t.csdn.cn/SQBWc

最后你需要注意的就是不要把endOf写成了endof,大小写要区分,还有还有,你需要引入moment,没有moment,npm i moment搞定!

posted @ 2023-03-14 16:36  叶乘风  阅读(48)  评论(0编辑  收藏  举报