2016-03-31 09:40:55 +08:00
|
|
|
---
|
|
|
|
order: 5
|
|
|
|
title: 禁止选项
|
|
|
|
---
|
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
|
|
|
|
|
|
|
````jsx
|
|
|
|
import { TimePicker } from 'antd';
|
|
|
|
|
2015-12-17 16:12:17 +08:00
|
|
|
function newArray(start, end) {
|
|
|
|
let result = [];
|
|
|
|
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() {
|
|
|
|
let hours = newArray(0, 60);
|
|
|
|
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
|
|
|
````
|