antd DatePicker 使用disabledDate 禁止某一种日期的情况总结

第一种:禁止当前月及当前月之后的所有月份

<DatePicker
  placeholder="请选择"
  style={{ width: '288px' }}
  picker="month"
  disabledDate={(current) => {
   // 禁止选中当前月及当前月之后的月份
   return current > moment().add(-1, 'month')
  }}
/>
                      

 

第二种:禁止之前操作过的月份

<DatePicker
  placeholder="请选择"
  style={{ width: '288px' }}
  picker="month"
  disabledDate={(current) => {
   // 禁止选中当前月及当前月之后的月份
   const month =  moment(current).format('yyyy-MM');
   return ['2022-01', '2022-02'].includes(month)
  }}
/>

 

posted @ 2022-06-07 15:35  凹润之之之  阅读(614)  评论(0编辑  收藏  举报