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

40 lines
704 B
Markdown
Raw Normal View History

2015-12-16 17:29:28 +08:00
# 禁止选项
2015-12-17 16:12:17 +08:00
- order: 5
2015-12-16 17:29:28 +08:00
2015-12-17 16:12:17 +08:00
限制选择 `20:30``23:30` 这个时间段。
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-17 16:12:17 +08:00
function disabledHours() {
let hours = newArray(0, 60);
hours.splice(20, 4);
return hours;
2015-12-16 17:29:28 +08:00
}
2015-12-17 16:12:17 +08:00
function disabledMinutes(h) {
if (h === 20) {
return newArray(0, 31);
} else if (h === 23) {
return newArray(30, 60);
} else {
return [];
}
2015-12-16 17:29:28 +08:00
}
ReactDOM.render(
2015-12-17 16:12:17 +08:00
<TimePicker disabledHours={disabledHours} disabledMinutes={disabledMinutes} />
2015-12-16 17:29:28 +08:00
, document.getElementById('components-time-picker-demo-disable-options'));
````