我正在为 React js 使用 material-ui v0.20.0 这是我的 DatePicker 组件
<Field
name='appointmentDate'
label="Select Date"
component={this.renderDatePicker}
/>
renderDatePicker = ({ input, label, meta: { touched, error }, ...custom,props }) => {
return (
<DatePicker
{...input}
{...custom}
autoOk={true}
floatingLabelText={label}
dateForm='MM/DD/YYYY'
shouldDisableDate={this.disabledDate}
minDate={ new Date()}
value={ input.value !== '' ? input.value : null }
onChange={(event, value) => input.onChange(value)}
/>
);
};
如果我想禁用任何一天,我应该在 disabledDate(){…} 中写什么?
原文由 jay pluto 发布,翻译遵循 CC BY-SA 4.0 许可协议
这是需要添加的示例代码。您可以参考此链接了解更多详情 - https://material-ui.com/components/pickers/#date-time-pickers
您可以根据需要添加条件以禁用日期。