Element-React Time Picker 时间选择器

用于选择或输入日期

固定时间点

提供几个固定的时间点供用户选择

使用 TimeSelect 标签,分别通过starendstep指定可选的起始时间、结束时间和步长
Element-React Time Picker 时间选择器

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 标签,分别通过starendstep指定可选的起始时间、结束时间和步长

Element-React Time Picker 时间选择器

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}
      />
  )
}

固定时间范围

若先选择开始时间,则结束时间内备选项的状态会随之改变
Element-React Time Picker 时间选择器

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
Element-React Time Picker 时间选择器

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}
      />
  )
}

公共参数

参数说明类型可选值默认值
align对齐方式stringleft, center, rightleft
placeholder占位内容string
isShowTrigger是否显示图标bool
isReadOnly只读booleanfalse
isDisabled是否禁用booleanfalse
onFocusonFocusfunc:(TimeSelectReactComponent)=>()
onBluronBlurfunc:(TimeSelectReactComponent)=>()
onChangeonChangefunc:(value)=>()

TimeSelect

参数说明类型可选值默认值
valuedate/null
start开始时间string09:00
end结束时间string18:00
step间隔时间string00:30
minTime最小时间date
maxTime最大时间date

TimePicker

参数说明类型可选值默认值
valuedate/null
selectableRange可选时间段,例如 18:30:00 - 20:30:00 或者传入数组 [09:30:00 - 12:00:00, 14:30:00 - 18:30:00]string/string[]

TimeRangePicker

参数说明类型可选值默认值
valuedate[]/null
selectableRange可选时间段,例如 18:30:00 - 20:30:00 或者传入数组 [09:30:00 - 12:00:00, 14:30:00 - 18:30:00]string/string[]
rangeSeparator选择范围时的分隔符string – 

作者:andy,如若转载,请注明出处:https://www.web176.com/elementreact/19997.html

(0)
打赏 支付宝 支付宝 微信 微信
andy的头像andy
上一篇 2023年5月11日
下一篇 2023年5月11日

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注