2015-12-17 16:12:17 +08:00
|
|
|
# 只显示部分选项
|
2015-12-16 17:29:28 +08:00
|
|
|
|
2015-12-17 16:12:17 +08:00
|
|
|
- order: 6
|
2015-12-16 17:29:28 +08:00
|
|
|
|
2015-12-17 16:12:17 +08:00
|
|
|
通过 `hideDisabledOptions` 将不可选的选项隐藏。
|
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
|
|
|
}
|
|
|
|
|
|
|
|
function disabledMinutes(h) {
|
2015-12-17 16:12:17 +08:00
|
|
|
return newArray(0, 60).filter(value => value % 10 !== 0);
|
2015-12-16 17:29:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function disabledSeconds(h, m) {
|
2015-12-17 16:12:17 +08:00
|
|
|
return newArray(0, 60).filter(value => value % 30 !== 0);
|
2015-12-16 17:29:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ReactDOM.render(
|
2015-12-17 16:12:17 +08:00
|
|
|
<TimePicker disabledMinutes={disabledMinutes} disabledSeconds={disabledSeconds} hideDisabledOptions />
|
2015-12-16 17:29:28 +08:00
|
|
|
, document.getElementById('components-time-picker-demo-hide-options'));
|
|
|
|
````
|