mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-12 20:43:11 +08:00
update demos
This commit is contained in:
parent
dcd6a05432
commit
8df1da99d9
@ -1,27 +1,39 @@
|
|||||||
# 禁止选项
|
# 禁止选项
|
||||||
|
|
||||||
- order: 5
|
- order: 5
|
||||||
|
|
||||||
禁止部分选项。
|
限制选择 `20:30` 到 `23:30` 这个时间段。
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
````jsx
|
````jsx
|
||||||
import { TimePicker } from 'antd';
|
import { TimePicker } from 'antd';
|
||||||
|
|
||||||
|
function newArray(start, end) {
|
||||||
|
let result = [];
|
||||||
|
for (let i = start; i < end; i++) {
|
||||||
|
result.push(i);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
function disabledHours() {
|
function disabledHours() {
|
||||||
return [0, 4, 8, 12, 16, 20];
|
let hours = newArray(0, 60);
|
||||||
|
hours.splice(20, 4);
|
||||||
|
return hours;
|
||||||
}
|
}
|
||||||
|
|
||||||
function disabledMinutes(h) {
|
function disabledMinutes(h) {
|
||||||
return [h % 60];
|
if (h === 20) {
|
||||||
}
|
return newArray(0, 31);
|
||||||
|
} else if (h === 23) {
|
||||||
function disabledSeconds(h, m) {
|
return newArray(30, 60);
|
||||||
return [h + m % 60];
|
} else {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ReactDOM.render(
|
ReactDOM.render(
|
||||||
<TimePicker defaultValue="12:08:23" disabledHours={disabledHours} disabledMinutes={disabledMinutes} disabledSeconds={disabledSeconds} />
|
<TimePicker disabledHours={disabledHours} disabledMinutes={disabledMinutes} />
|
||||||
, document.getElementById('components-time-picker-demo-disable-options'));
|
, document.getElementById('components-time-picker-demo-disable-options'));
|
||||||
````
|
````
|
||||||
|
@ -1,27 +1,31 @@
|
|||||||
# 隐藏选项
|
# 只显示部分选项
|
||||||
|
|
||||||
- order: 6
|
- order: 6
|
||||||
|
|
||||||
禁止部分选项。
|
通过 `hideDisabledOptions` 将不可选的选项隐藏。
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
````jsx
|
````jsx
|
||||||
import { TimePicker } from 'antd';
|
import { TimePicker } from 'antd';
|
||||||
|
|
||||||
function disabledHours() {
|
function newArray(start, end) {
|
||||||
return [0, 4, 8, 12, 16, 20];
|
let result = [];
|
||||||
|
for (let i = start; i < end; i++) {
|
||||||
|
result.push(i);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function disabledMinutes(h) {
|
function disabledMinutes(h) {
|
||||||
return [h % 60];
|
return newArray(0, 60).filter(value => value % 10 !== 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
function disabledSeconds(h, m) {
|
function disabledSeconds(h, m) {
|
||||||
return [h + m % 60];
|
return newArray(0, 60).filter(value => value % 30 !== 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReactDOM.render(
|
ReactDOM.render(
|
||||||
<TimePicker defaultValue="12:08:23" disabledHours={disabledHours} disabledMinutes={disabledMinutes} disabledSeconds={disabledSeconds} hideDisabledOptions />
|
<TimePicker disabledMinutes={disabledMinutes} disabledSeconds={disabledSeconds} hideDisabledOptions />
|
||||||
, document.getElementById('components-time-picker-demo-hide-options'));
|
, document.getElementById('components-time-picker-demo-hide-options'));
|
||||||
````
|
````
|
||||||
|
Loading…
Reference in New Issue
Block a user