Time-picker 时间选择器
代码演示
固定时间点
通过picker-options设置固定时间点。
查看代码 < />
<template>
  <section class="time-select-demo">
    <w-time-select v-model="value1"
      :picker-options="{
        start: '08:30',
        step: '00:15',
        end: '18:30'
      }"
      placeholder="选择时间">
    </w-time-select>
  </section>
</template>
<script>
export default {
  data () {
    return {
      value1: ''
    }
  }
}
</script>任意时间点
选择任意时间点。
查看代码 < />
<template>
  <section class="time-picker-demo">
    <w-time-picker v-model="value2"
      :picker-options="{
        selectableRange: '18:30:00 - 20:30:00'
      }"
      placeholder="选择时间">
    </w-time-picker>
    <w-time-picker v-model="value3"
      arrow-control
      :picker-options="{
        selectableRange: '18:30:00 - 20:30:00'
      }"
      placeholder="选择时间">
    </w-time-picker>
  </section>
</template>
<script>
export default {
  data () {
    return {
      value2: new Date(2016, 9, 10, 18, 40),
      value3: new Date(2016, 9, 10, 18, 40)
    }
  }
}
</script>
<style scoped lang="scss">
.time-picker-demo {
  .w-date-editor+.w-date-editor {
    margin-left: 10px;
  }
}
</style>固定时间范围
若先选择开始时间,则结束时间内备选项的状态会随之改变。
查看代码 < />
<template>
  <section class="time-select-demo">
    <w-time-select v-model="startTime"
      :picker-options="{
        start: '08:30',
        step: '00:15',
        end: '18:30'
      }"
      placeholder="开始时间">
    </w-time-select>
    <w-time-select v-model="endTime"
      :picker-options="{
        start: '08:30',
        step: '00:15',
        end: '18:30',
      }"
      placeholder="结束时间">
    </w-time-select>
  </section>
</template>
<script>
export default {
  data () {
    return {
      startTime: '',
      endTime: ''
    }
  }
}
</script>
<style scoped lang="scss">
.time-select-demo {
  .w-date-editor+.w-date-editor {
    margin-left: 10px;
  }
}
</style> 至    
 至    
可选择任意的时间范围
可选择任意的时间范围。
查看代码 < />
<template>
  <section class="time-picker-demo">
    <div class="block">
    <w-time-picker v-model="value4" is-range
      :picker-options="{
          selectableRange: '18:30:00 - 20:30:00'
      }"
      range-separator="至"
      start-placeholder="开始时间"
      placeholder="选择时间范围"
      end-placeholder="结束时间">
    </w-time-picker>
    </div>
    <div class="block">
    <w-time-picker v-model="value5" is-range arrow-control
      :picker-options="{
          selectableRange: '18:30:00 - 20:30:00'
      }"
      range-separator="至"
      start-placeholder="开始时间"
      placeholder="选择时间范围"
      end-placeholder="结束时间">
    </w-time-picker>
    </div>
  </section>
</template>
<script>
export default {
  data () {
    return {
      value4: [new Date(2016, 9, 10, 8, 40), new Date(2016, 9, 10, 9, 40)],
      value5: [new Date(2016, 9, 10, 8, 40), new Date(2016, 9, 10, 9, 40)]
    }
  }
}
</script>
<style scoped lang="scss">
.time-picker-demo {
  .block {
    padding: 20px 0;
  }
}
</style>API
Attributes
| 参数 | 说明 | 类型 | 可选值 | 默认值 | Version | 
|---|---|---|---|---|---|
| align | 对齐方式 | String | left / center / right | left | |
| arrow-control | 是否使用箭头进行时间选择,仅对<w-time-picker>有效 |  Boolean | — | false | |
| clearable | 是否显示清除按钮 | Boolean | — | true | |
| clear-icon | 自定义清空图标的类名 | String | — | w-icon-close | |
| disabled | 禁用 | Boolean | — | false | |
| default-value | 可选,选择器打开时默认显示的时间 | Date(TimePicker) / String(TimeSelect) | 可被new Date()解析(TimePicker) / 可选值(TimeSelect) |  — | |
| end-placeholder | 范围选择时开始日期的占位内容 | String | — | — | |
| editable | 文本框可输入 | Boolean | — | true | |
| is-range | 是否为时间范围选择,仅对<w-time-picker>有效 |  Boolean | — | false | |
| placeholder | 非范围选择时的占位内容 | String | — | — | |
| prefix-icon | 自定义头部图标的类名 | String | — | w-icon-time | |
| range-separator | 选择范围时的分隔符 | String | - | '-' | |
| readonly | 完全只读 | Boolean | — | false | |
| name | 原生属性 | String | — | — | |
| popper-class | TimePicker 下拉框的类名 | String | — | — | |
| picker-options | 当前时间日期选择器特有的选项参考下表 | Object | — | {} | |
| start-placeholder | 范围选择时开始日期的占位内容 | String | — | — | |
| size | 输入框尺寸 | String | medium / small / mini | — | |
| value-format | 可选,仅TimePicker时可用,绑定值的格式。不指定则绑定值为 Date 对象 | String | 见DatePicker日期组件 | — | |
| value / v-model | 绑定值 | Date(TimePicker) / String(TimeSelect) | — | — | 
Time Select Options
| 参数 | 说明 | 类型 | 可选值 | 默认值 | Version | 
|---|---|---|---|---|---|
| end | 结束时间 | String | — | 18:00 | |
| minTime | 最小时间,小于该时间的时间段将被禁用 | String | — | 00:00 | |
| maxTime | 最大时间,大于该时间的时间段将被禁用 | String | — | — | |
| step | 间隔时间 | String | — | 00:30 | |
| start | 开始时间 | String | — | 09:00 | 
Time Picker Options
| 参数 | 说明 | 类型 | 可选值 | 默认值 | Version | 
|---|---|---|---|---|---|
| format | 时间格式化(TimePicker) | String | 小时:HH,分:mm,秒:ss,AM/PM A |  'HH:mm:ss' | |
| selectableRange | 可选时间段,例如'18:30:00 - 20:30:00'或者传入数组['09:30:00 - 12:00:00', '14:30:00 - 18:30:00'] |  String / Array | — | — | 
Events
| 事件名 | 说明 | 参数 | Version | 
|---|---|---|---|
| blur | 当 input 失去焦点时触发 | 组件实例 | |
| change | 用户确认选定的值时触发 | 组件绑定值 | |
| focus | 当 input 获得焦点时触发 | 组件实例 | 
Methods
| 方法名 | 说明 | 参数 | Version | 
|---|---|---|---|
| focus | 使 input 获取焦点 | - | 
贡献者
| 类型 | 参与者 | 
|---|---|
| 设计者 | UED视觉组 | 
| 维护者 | UED前端组 |