ant-design/components/time-picker/demo/hide-options.md

32 lines
605 B
Markdown
Raw Normal View History

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
}
2015-12-27 16:20:59 +08:00
function disabledMinutes() {
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
}
2015-12-27 16:20:59 +08:00
function disabledSeconds() {
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 />
, mountNode);
2015-12-16 17:29:28 +08:00
````