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

39 lines
728 B
Markdown
Raw Normal View History

2016-03-31 09:40:55 +08:00
---
order: 6
2016-07-26 11:03:44 +08:00
title:
zh-CN: 只显示部分选项
en-US: Show part of options.
2016-03-31 09:40:55 +08:00
---
2015-12-16 17:29:28 +08:00
2016-07-26 11:03:44 +08:00
## zh-CN
通过 hideDisabledOptions 将不可选的选项隐藏。
## en-US
use `hideDisabledOptions` to hide the disabled options.
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-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
````