You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
771 B

---
order: 5
title:
zh-CN: 禁止选项
en-US: Specify the time that cannot be selected
---
## zh-CN
9 years ago
限制选择 `20:30``23:30` 这个时间段。
## en-US
You can't select the time from `20:30` to `23:30`.
````jsx
import { TimePicker } from 'antd';
9 years ago
function newArray(start, end) {
8 years ago
const result = [];
9 years ago
for (let i = start; i < end; i++) {
result.push(i);
}
return result;
}
9 years ago
function disabledHours() {
8 years ago
const hours = newArray(0, 60);
9 years ago
hours.splice(20, 4);
return hours;
}
9 years ago
function disabledMinutes(h) {
if (h === 20) {
return newArray(0, 31);
} else if (h === 23) {
return newArray(30, 60);
}
return [];
}
ReactDOM.render(
9 years ago
<TimePicker disabledHours={disabledHours} disabledMinutes={disabledMinutes} />
, mountNode);
````