afc163
9 years ago
10 changed files with 100 additions and 34 deletions
@ -0,0 +1,39 @@ |
|||
# 禁止选项 |
|||
|
|||
- order: 5 |
|||
|
|||
限制选择 `20:30` 到 `23:30` 这个时间段。 |
|||
|
|||
--- |
|||
|
|||
````jsx |
|||
import { TimePicker } from 'antd'; |
|||
|
|||
function newArray(start, end) { |
|||
let result = []; |
|||
for (let i = start; i < end; i++) { |
|||
result.push(i); |
|||
} |
|||
return result; |
|||
} |
|||
|
|||
function disabledHours() { |
|||
let hours = newArray(0, 60); |
|||
hours.splice(20, 4); |
|||
return hours; |
|||
} |
|||
|
|||
function disabledMinutes(h) { |
|||
if (h === 20) { |
|||
return newArray(0, 31); |
|||
} else if (h === 23) { |
|||
return newArray(30, 60); |
|||
} else { |
|||
return []; |
|||
} |
|||
} |
|||
|
|||
ReactDOM.render( |
|||
<TimePicker disabledHours={disabledHours} disabledMinutes={disabledMinutes} /> |
|||
, document.getElementById('components-time-picker-demo-disable-options')); |
|||
```` |
@ -0,0 +1,31 @@ |
|||
# 只显示部分选项 |
|||
|
|||
- 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')); |
|||
```` |
@ -1,15 +0,0 @@ |
|||
# 特定选项 |
|||
|
|||
- order: 3 |
|||
|
|||
分钟只提供特定的选择,同时可以通过 `hourOptions` 和 `secondOptions` 对小时和秒进行特殊的限定。 |
|||
|
|||
--- |
|||
|
|||
````jsx |
|||
import { TimePicker } from 'antd'; |
|||
|
|||
ReactDOM.render( |
|||
<TimePicker defaultValue="12:30:23" format="HH:mm" minuteOptions={[0, 30]} /> |
|||
, document.getElementById('components-time-picker-demo-special-minutes')); |
|||
```` |
Loading…
Reference in new issue