Antd 4.x 版本 RangePicker 时间日期选择器 禁用当前时间往后的日期
<RangePicker format={'YYYY-MM-DD HH:mm:ss'} showTime={{ format: 'HH:mm:ss' }} disabledDate={disabledDate} disabledTime={disabledTime} />
组件
const disabledDate: RangePickerProps['disabledDate'] = (current) => { return current && current > moment().startOf('day'); };
禁止选择未来的天数
function disabledTime(dates: any) { const hours = moment().hours(); const minutes = moment().minutes(); const seconds = moment().seconds(); if (dates && moment(dates).date() === moment().date()) { return { disabledHours: () => range(hours + 1, 24), disabledMinutes: () => range(minutes + 1, 60), disabledSeconds: () => range(seconds + 1, 60), }; } return { disabledHours: () => [], disabledMinutes: () => [], disabledSeconds: () => [] }; }
禁止选择未来的时分秒