用于選擇或輸入日期
提供幾個(gè)固定的時(shí)間點(diǎn)供用戶選擇
使用 TimeSelect
標(biāo)簽,分別通過star
、end
和step
指定可選的起始時(shí)間、結(jié)束時(shí)間和步長
constructor(props) {
super(props)
this.state = {
value: new Date(2016, 9, 10, 8, 30),
}
}
handleUpdate(value) {
console.debug('time-select update: ', value)
}
render() {
return (
<TimeSelect
start="08:30"
step="00:15"
end="18:30"
maxTime="12:30"
onChange={this.handleUpdate.bind(this)}
value={this.state.value}
placeholder="選擇時(shí)間"
/>
)
}
可以選擇任意時(shí)間
使用 TimePicker
標(biāo)簽,分別通過star
、end
和step
指定可選的起始時(shí)間、結(jié)束時(shí)間和步長
constructor(props) {
super(props)
this.state = {
value: new Date(2016, 9, 10, 18, 40)
}
}
handleUpdate(value) {
console.debug('time-picker update: ', value)
}
render() {
return (
<TimePicker
onChange={this.handleUpdate.bind(this)}
selectableRange="18:30:00 - 20:30:00"
placeholder="選擇時(shí)間"
value={this.state.value}
/>
)
}
若先選擇開始時(shí)間,則結(jié)束時(shí)間內(nèi)備選項(xiàng)的狀態(tài)會隨之改變
constructor(props) {
super(props)
this.state = {
startDate: new Date(2016, 9, 10, 14, 30),
endDate: new Date(2016, 9, 10, 15, 30)
}
}
handleStartUpdate(startDate) {
console.debug('time-select startDate update: ', startDate)
this.setState({startDate})
}
handleEndUpdate(endDate){
console.debug('time-select endDate update: ', endDate)
this.setState({endDate})
}
render() {
return (
<div>
<TimeSelect
start="08:30"
step="00:15"
end="18:30"
onChange={this.handleStartUpdate.bind(this)}
value={this.state.startDate}
placeholder="選擇時(shí)間"
/>
<TimeSelect
start="08:30"
step="00:15"
end="18:30"
onChange={this.handleEndUpdate.bind(this)}
value={this.state.endDate}
minTime={this.state.startDate}
placeholder="選擇時(shí)間"
/>
</div>
)
}
可選擇任意的時(shí)間范圍
blah
constructor(props) {
super(props)
this.state = {
value: [new Date(2016, 9, 10, 8, 40), new Date(2016, 9, 10, 9, 40)]
}
}
handleUpdate(value) {
console.debug('time-picker update: ', value)
}
render() {
return (
<TimeRangePicker
pickerWidth={300}
onChange={this.handleUpdate.bind(this)}
placeholder="選擇時(shí)間"
value={this.state.value}
/>
)
}
參數(shù) | 說明 | 類型 | 可選值 | 默認(rèn)值 |
---|---|---|---|---|
align | 對齊方式 | string | left, center, right | left |
placeholder | 占位內(nèi)容 | string | — | — |
isShowTrigger | 是否顯示圖標(biāo) | bool | - | - |
isReadOnly | 只讀 | boolean | — | false |
isDisabled | 是否禁用 | boolean | — | false |
onFocus | onFocus | func:(TimeSelectReactComponent)=>() | — | - |
onBlur | onBlur | func:(TimeSelectReactComponent)=>() | — | - |
onChange | onChange | func:(value)=>() | — | - |
參數(shù) | 說明 | 類型 | 可選值 | 默認(rèn)值 |
---|---|---|---|---|
value | 值 | date/null | — | - |
start | 開始時(shí)間 | string | — | 09:00 |
end | 結(jié)束時(shí)間 | string | — | 18:00 |
step | 間隔時(shí)間 | string | — | 00:30 |
minTime | 最小時(shí)間 | date | — | - |
maxTime | 最大時(shí)間 | date | — | - |
參數(shù) | 說明 | 類型 | 可選值 | 默認(rèn)值 |
---|---|---|---|---|
value | 值 | date/null | — | - |
selectableRange | 可選時(shí)間段,例如 '18:30:00 - 20:30:00' 或者傳入數(shù)組 ['09:30:00 - 12:00:00', '14:30:00 - 18:30:00'] |
string/string[] | — | — |
參數(shù) | 說明 | 類型 | 可選值 | 默認(rèn)值 |
---|---|---|---|---|
value | 值 | date[]/null | — | - |
selectableRange | 可選時(shí)間段,例如 '18:30:00 - 20:30:00' 或者傳入數(shù)組 ['09:30:00 - 12:00:00', '14:30:00 - 18:30:00'] |
string/string[] | — | — |
rangeSeparator | 選擇范圍時(shí)的分隔符 | string | - | ' - ' |
更多建議: