UNPKG

adui

Version:

<div> <img src="https://wxa.wxs.qq.com/mpweb/delivery/legacy/wxadtouch/upload/t1/od834zef_52939fc6.png" style="margin:40px 0 0 -8px; background-color: #fcfcfc; box-shadow: none;" /> </div>

30 lines (26 loc) 673 B
--- order: 1 title: zh-CN: 限制选择 en-US: DisabledDays --- 使用 `maxDate`,`minDate` `disabledDays` 限制可选择的日期: ```jsx const [value, setValue] = useState(new Date()) /** * 示例限制:一个月前,一个月后,所有星期天,所有 6 */ const oneMonthBefore = new Date() const oneMonthLater = new Date() oneMonthBefore.setMonth(new Date().getMonth() - 1) oneMonthLater.setMonth(new Date().getMonth() + 1) return ( <DatePicker value={value} maxDate={oneMonthLater} minDate={oneMonthBefore} disabledDays={(day) => day.getDay() === 0 || day.getDate() === 6} onChange={(val) => setValue(val)} /> ) ```