用于選擇或輸入日期
提供幾個固定的時間點供用戶選擇
使用 TimeSelect
標簽,分別通過star
、end
和step
指定可選的起始時間、結束時間和步長
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="選擇時間"
/>
)
}
可以選擇任意時間
使用 TimePicker
標簽,分別通過star
、end
和step
指定可選的起始時間、結束時間和步長
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="選擇時間"
value={this.state.value}
/>
)
}
若先選擇開始時間,則結束時間內備選項的狀態(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="選擇時間"
/>
<TimeSelect
start="08:30"
step="00:15"
end="18:30"
onChange={this.handleEndUpdate.bind(this)}
value={this.state.endDate}
minTime={this.state.startDate}
placeholder="選擇時間"
/>
</div>
)
}
可選擇任意的時間范圍
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="選擇時間"
value={this.state.value}
/>
)
}
參數(shù) | 說明 | 類型 | 可選值 | 默認值 |
---|---|---|---|---|
align | 對齊方式 | string | left, center, right | left |
placeholder | 占位內容 | string | — | — |
isShowTrigger | 是否顯示圖標 | bool | - | - |
isReadOnly | 只讀 | boolean | — | false |
isDisabled | 是否禁用 | boolean | — | false |
onFocus | onFocus | func:(TimeSelectReactComponent)=>() | — | - |
onBlur | onBlur | func:(TimeSelectReactComponent)=>() | — | - |
onChange | onChange | func:(value)=>() | — | - |
參數(shù) | 說明 | 類型 | 可選值 | 默認值 |
---|---|---|---|---|
value | 值 | date/null | — | - |
start | 開始時間 | string | — | 09:00 |
end | 結束時間 | string | — | 18:00 |
step | 間隔時間 | string | — | 00:30 |
minTime | 最小時間 | date | — | - |
maxTime | 最大時間 | date | — | - |
參數(shù) | 說明 | 類型 | 可選值 | 默認值 |
---|---|---|---|---|
value | 值 | date/null | — | - |
selectableRange | 可選時間段,例如 '18:30:00 - 20:30:00' 或者傳入數(shù)組 ['09:30:00 - 12:00:00', '14:30:00 - 18:30:00'] |
string/string[] | — | — |
參數(shù) | 說明 | 類型 | 可選值 | 默認值 |
---|---|---|---|---|
value | 值 | date[]/null | — | - |
selectableRange | 可選時間段,例如 '18:30:00 - 20:30:00' 或者傳入數(shù)組 ['09:30:00 - 12:00:00', '14:30:00 - 18:30:00'] |
string/string[] | — | — |
rangeSeparator | 選擇范圍時的分隔符 | string | - | ' - ' |
更多建議: