2016-03-31 09:40:55 +08:00
|
|
|
---
|
|
|
|
order: 5
|
2016-07-26 11:03:44 +08:00
|
|
|
title:
|
|
|
|
zh-CN: 禁止选项
|
|
|
|
en-US: Specify the time that cannot be selected
|
2016-03-31 09:40:55 +08:00
|
|
|
---
|
2016-07-26 11:03:44 +08:00
|
|
|
## zh-CN
|
2015-12-16 17:29:28 +08:00
|
|
|
|
2015-12-17 16:12:17 +08:00
|
|
|
限制选择 `20:30` 到 `23:30` 这个时间段。
|
2015-12-16 17:29:28 +08:00
|
|
|
|
2016-07-26 11:03:44 +08:00
|
|
|
## en-US
|
|
|
|
|
|
|
|
You can't select the time from `20:30` to `23:30`.
|
|
|
|
|
2015-12-16 17:29:28 +08:00
|
|
|
````jsx
|
|
|
|
import { TimePicker } from 'antd';
|
|
|
|
|
2015-12-17 16:12:17 +08:00
|
|
|
function newArray(start, end) {
|
2016-07-21 18:05:15 +08:00
|
|
|
const result = [];
|
2015-12-17 16:12:17 +08:00
|
|
|
for (let i = start; i < end; i++) {
|
|
|
|
result.push(i);
|
|
|
|
}
|
|
|
|
return result;
|
2015-12-16 17:29:28 +08:00
|
|
|
}
|
|
|
|
|
2015-12-17 16:12:17 +08:00
|
|
|
function disabledHours() {
|
2016-07-21 18:05:15 +08:00
|
|
|
const hours = newArray(0, 60);
|
2015-12-17 16:12:17 +08:00
|
|
|
hours.splice(20, 4);
|
|
|
|
return hours;
|
2015-12-16 17:29:28 +08:00
|
|
|
}
|
|
|
|
|
2015-12-17 16:12:17 +08:00
|
|
|
function disabledMinutes(h) {
|
|
|
|
if (h === 20) {
|
|
|
|
return newArray(0, 31);
|
|
|
|
} else if (h === 23) {
|
|
|
|
return newArray(30, 60);
|
|
|
|
}
|
2016-01-07 16:29:12 +08:00
|
|
|
return [];
|
2015-12-16 17:29:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ReactDOM.render(
|
2015-12-17 16:12:17 +08:00
|
|
|
<TimePicker disabledHours={disabledHours} disabledMinutes={disabledMinutes} />
|
2015-12-29 12:08:58 +08:00
|
|
|
, mountNode);
|
2015-12-16 17:29:28 +08:00
|
|
|
````
|