mirror of
https://github.com/ant-design/ant-design.git
synced 2025-08-01 05:06:53 +08:00
32 lines
668 B
Markdown
32 lines
668 B
Markdown
# 只显示部分选项
|
|
|
|
- order: 6
|
|
|
|
通过 `hideDisabledOptions` 将不可选的选项隐藏。
|
|
|
|
---
|
|
|
|
````jsx
|
|
import { TimePicker } from 'antd';
|
|
|
|
function newArray(start, end) {
|
|
let result = [];
|
|
for (let i = start; i < end; i++) {
|
|
result.push(i);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
function disabledMinutes(h) {
|
|
return newArray(0, 60).filter(value => value % 10 !== 0);
|
|
}
|
|
|
|
function disabledSeconds(h, m) {
|
|
return newArray(0, 60).filter(value => value % 30 !== 0);
|
|
}
|
|
|
|
ReactDOM.render(
|
|
<TimePicker disabledMinutes={disabledMinutes} disabledSeconds={disabledSeconds} hideDisabledOptions />
|
|
, document.getElementById('components-time-picker-demo-hide-options'));
|
|
````
|