2016-07-27 14:15:02 +08:00
|
|
|
|
<style>
|
|
|
|
|
.demo-box {
|
|
|
|
|
.el-date-editor + .el-date-editor {
|
|
|
|
|
margin-left: 10px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
|
2016-11-07 16:25:56 +08:00
|
|
|
|
## TimePicker 时间选择器
|
2016-09-10 10:01:48 +08:00
|
|
|
|
|
2016-08-27 21:24:16 +08:00
|
|
|
|
用于选择或输入日期
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
2016-08-27 21:24:16 +08:00
|
|
|
|
### 固定时间点
|
|
|
|
|
|
|
|
|
|
提供几个固定的时间点供用户选择
|
|
|
|
|
|
|
|
|
|
:::demo 使用 el-time-select 标签,分别通过`star`、`end`和`step`指定可选的起始时间、结束时间和步长
|
2016-07-27 14:15:02 +08:00
|
|
|
|
```html
|
|
|
|
|
<el-time-select
|
2016-08-27 21:24:16 +08:00
|
|
|
|
v-model="value1"
|
2016-07-27 14:15:02 +08:00
|
|
|
|
:picker-options="{
|
|
|
|
|
start: '08:30',
|
|
|
|
|
step: '00:15',
|
|
|
|
|
end: '18:30'
|
|
|
|
|
}"
|
|
|
|
|
placeholder="选择时间">
|
|
|
|
|
</el-time-select>
|
2016-11-14 18:10:52 +08:00
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
export default {
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
value1: ''
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
2016-07-27 14:15:02 +08:00
|
|
|
|
```
|
2016-08-27 21:24:16 +08:00
|
|
|
|
:::
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
2016-08-27 21:24:16 +08:00
|
|
|
|
### 任意时间点
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
2016-08-27 21:24:16 +08:00
|
|
|
|
可以选择任意时间
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
2017-10-11 18:00:58 +08:00
|
|
|
|
:::demo 使用 el-time-picker 标签,通过`selectableRange`限制可选时间范围。提供了两种交互方式:默认情况下通过鼠标滚轮进行选择,打开`arrow-control`属性则通过界面上的箭头进行选择。
|
2016-07-27 14:15:02 +08:00
|
|
|
|
```html
|
2016-09-27 11:12:11 +08:00
|
|
|
|
<template>
|
|
|
|
|
<el-time-picker
|
|
|
|
|
v-model="value2"
|
|
|
|
|
:picker-options="{
|
|
|
|
|
selectableRange: '18:30:00 - 20:30:00'
|
|
|
|
|
}"
|
|
|
|
|
placeholder="任意时间点">
|
|
|
|
|
</el-time-picker>
|
2017-10-11 18:00:58 +08:00
|
|
|
|
<el-time-picker
|
|
|
|
|
arrow-control
|
|
|
|
|
v-model="value3"
|
|
|
|
|
:picker-options="{
|
|
|
|
|
selectableRange: '18:30:00 - 20:30:00'
|
|
|
|
|
}"
|
|
|
|
|
placeholder="任意时间点">
|
|
|
|
|
</el-time-picker>
|
2016-09-27 11:12:11 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
export default {
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
2017-10-11 18:00:58 +08:00
|
|
|
|
value2: new Date(2016, 9, 10, 18, 40),
|
|
|
|
|
value3: new Date(2016, 9, 10, 18, 40)
|
2016-09-27 11:12:11 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
2016-07-27 14:15:02 +08:00
|
|
|
|
```
|
2016-08-27 21:24:16 +08:00
|
|
|
|
:::
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
2016-08-27 21:24:16 +08:00
|
|
|
|
### 固定时间范围
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
2016-08-27 21:24:16 +08:00
|
|
|
|
若先选择开始时间,则结束时间内备选项的状态会随之改变
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
2016-08-27 21:24:16 +08:00
|
|
|
|
:::demo
|
2016-07-27 14:15:02 +08:00
|
|
|
|
```html
|
2016-09-27 11:12:11 +08:00
|
|
|
|
<template>
|
|
|
|
|
<el-time-select
|
|
|
|
|
placeholder="起始时间"
|
|
|
|
|
v-model="startTime"
|
|
|
|
|
:picker-options="{
|
|
|
|
|
start: '08:30',
|
|
|
|
|
step: '00:15',
|
|
|
|
|
end: '18:30'
|
|
|
|
|
}">
|
|
|
|
|
</el-time-select>
|
|
|
|
|
<el-time-select
|
|
|
|
|
placeholder="结束时间"
|
|
|
|
|
v-model="endTime"
|
|
|
|
|
:picker-options="{
|
|
|
|
|
start: '08:30',
|
|
|
|
|
step: '00:15',
|
|
|
|
|
end: '18:30',
|
|
|
|
|
minTime: startTime
|
|
|
|
|
}">
|
|
|
|
|
</el-time-select>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
export default {
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
startTime: '',
|
|
|
|
|
endTime: ''
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
2016-07-27 14:15:02 +08:00
|
|
|
|
```
|
2016-08-27 21:24:16 +08:00
|
|
|
|
:::
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
2016-08-27 21:24:16 +08:00
|
|
|
|
### 任意时间范围
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
2016-08-27 21:24:16 +08:00
|
|
|
|
可选择任意的时间范围
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
2017-10-11 18:00:58 +08:00
|
|
|
|
:::demo 添加`is-range`属性即可选择时间范围,同样支持`arrow-control`属性。
|
2016-07-27 14:15:02 +08:00
|
|
|
|
```html
|
2016-09-27 11:12:11 +08:00
|
|
|
|
<template>
|
|
|
|
|
<el-time-picker
|
|
|
|
|
is-range
|
2017-10-11 18:00:58 +08:00
|
|
|
|
v-model="value4"
|
|
|
|
|
range-separator="至"
|
|
|
|
|
start-placeholder="开始时间"
|
|
|
|
|
end-placeholder="结束时间"
|
|
|
|
|
placeholder="选择时间范围">
|
|
|
|
|
</el-time-picker>
|
|
|
|
|
<el-time-picker
|
|
|
|
|
is-range
|
|
|
|
|
arrow-control
|
|
|
|
|
v-model="value5"
|
2017-09-23 12:46:37 +08:00
|
|
|
|
range-separator="至"
|
|
|
|
|
start-placeholder="开始时间"
|
|
|
|
|
end-placeholder="结束时间"
|
2016-09-27 11:12:11 +08:00
|
|
|
|
placeholder="选择时间范围">
|
|
|
|
|
</el-time-picker>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
export default {
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
2017-10-11 18:00:58 +08:00
|
|
|
|
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)]
|
2016-09-27 11:12:11 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
2016-07-27 14:15:02 +08:00
|
|
|
|
```
|
2016-08-27 21:24:16 +08:00
|
|
|
|
:::
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
export default {
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
2016-12-09 18:12:56 +08:00
|
|
|
|
value1: '',
|
2016-09-10 10:01:48 +08:00
|
|
|
|
value2: new Date(2016, 9, 10, 18, 40),
|
2017-10-11 18:00:58 +08:00
|
|
|
|
value3: new Date(2016, 9, 10, 18, 40),
|
|
|
|
|
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)],
|
2016-07-27 14:15:02 +08:00
|
|
|
|
startTime: '',
|
2016-08-27 21:24:16 +08:00
|
|
|
|
endTime: ''
|
2016-07-27 14:15:02 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
2016-08-27 21:24:16 +08:00
|
|
|
|
### Attributes
|
2016-07-27 14:15:02 +08:00
|
|
|
|
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|
|
|
|
|
|---------- |-------------- |---------- |-------------------------------- |-------- |
|
2016-11-13 11:45:38 +08:00
|
|
|
|
| readonly | 完全只读 | boolean | — | false |
|
2016-12-29 20:53:33 +08:00
|
|
|
|
| disabled | 禁用 | boolean | — | false |
|
|
|
|
|
| editable | 文本框可输入 | boolean | — | true |
|
|
|
|
|
| clearable | 是否显示清除按钮 | boolean | — | true |
|
2017-09-19 22:35:57 +08:00
|
|
|
|
| size | 输入框尺寸 | string | medium / small / mini | — |
|
2017-09-23 12:46:37 +08:00
|
|
|
|
| placeholder | 非范围选择时的占位内容 | string | — | — |
|
|
|
|
|
| start-placeholder | 范围选择时开始日期的占位内容 | string | — | — |
|
|
|
|
|
| end-placeholder | 范围选择时开始日期的占位内容 | string | — | — |
|
2017-10-11 18:00:58 +08:00
|
|
|
|
| is-range | 是否为时间范围选择,仅对`<el-time-picker>`有效 | boolean | — | false |
|
|
|
|
|
| arrow-control | 是否使用箭头进行时间选择,仅对`<el-time-picker>`有效 | boolean | — | false |
|
2017-09-19 22:35:57 +08:00
|
|
|
|
| value | 绑定值 | date(TimePicker) / string(TimeSelect) | — | — |
|
|
|
|
|
| align | 对齐方式 | string | left / center / right | left |
|
2016-12-20 16:38:47 +08:00
|
|
|
|
| popper-class | TimePicker 下拉框的类名 | string | — | — |
|
2016-12-13 22:52:29 +08:00
|
|
|
|
| picker-options | 当前时间日期选择器特有的选项参考下表 | object | — | {} |
|
2017-09-23 12:46:37 +08:00
|
|
|
|
| range-separator | 选择范围时的分隔符 | string | - | '-' |
|
2018-01-21 17:13:25 +08:00
|
|
|
|
| value-format | 可选,仅TimePicker时可用,绑定值的格式。不指定则绑定值为 Date 对象 | string | 见[日期格式](#/zh-CN/component/date-picker#ri-qi-ge-shi) | — |
|
2017-10-10 17:49:41 +08:00
|
|
|
|
| default-value | 可选,选择器打开时默认显示的时间 | Date(TimePicker) / string(TimeSelect) | 可被`new Date()`解析(TimePicker) / 可选值(TimeSelect) | — |
|
2017-07-30 16:26:05 +08:00
|
|
|
|
| name | 原生属性 | string | — | — |
|
2018-01-15 22:02:03 +08:00
|
|
|
|
| prefix-icon | 自定义头部图标的类名 | string | — | el-icon-time |
|
|
|
|
|
| clear-icon | 自定义清空图标的类名 | string | — | el-icon-circle-close |
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
2016-08-27 21:24:16 +08:00
|
|
|
|
### Time Select Options
|
2016-07-27 14:15:02 +08:00
|
|
|
|
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|
|
|
|
|
|---------- |-------------- |---------- |-------------------------------- |-------- |
|
2016-09-02 13:56:47 +08:00
|
|
|
|
| start | 开始时间 | string | — | 09:00 |
|
|
|
|
|
| end | 结束时间 | string | — | 18:00 |
|
|
|
|
|
| step | 间隔时间 | string | — | 00:30 |
|
|
|
|
|
| minTime | 最小时间,小于该时间的时间段将被禁用 | string | — | 00:00 |
|
2016-12-29 20:53:33 +08:00
|
|
|
|
| maxTime | 最大时间,大于该时间的时间段将被禁用 | string | — | — |
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
2016-08-27 21:24:16 +08:00
|
|
|
|
### Time Picker Options
|
2016-07-27 14:15:02 +08:00
|
|
|
|
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|
|
|
|
|
|---------- |-------------- |---------- |-------------------------------- |-------- |
|
2017-09-19 22:35:57 +08:00
|
|
|
|
| selectableRange | 可选时间段,例如`'18:30:00 - 20:30:00'`或者传入数组`['09:30:00 - 12:00:00', '14:30:00 - 18:30:00']` | string / array | — | — |
|
2017-12-09 01:21:31 +08:00
|
|
|
|
| format | 时间格式化(TimePicker) | string | 小时:`HH`,分:`mm`,秒:`ss`,AM/PM `A` | 'HH:mm:ss' |
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
2016-12-23 17:34:40 +08:00
|
|
|
|
### Events
|
2017-09-19 22:35:57 +08:00
|
|
|
|
| 事件名 | 说明 | 参数 |
|
2016-12-23 17:34:40 +08:00
|
|
|
|
|---------|--------|---------|
|
2017-10-10 17:49:41 +08:00
|
|
|
|
| change | 用户确认选定的值时触发 | 组件绑定值 |
|
2017-12-12 15:46:19 +08:00
|
|
|
|
| blur | 当 input 失去焦点时触发 | 组件实例 |
|
|
|
|
|
| focus | 当 input 获得焦点时触发 | 组件实例 |
|
2017-07-18 13:47:35 +08:00
|
|
|
|
|
|
|
|
|
### Methods
|
|
|
|
|
| 方法名 | 说明 | 参数 |
|
|
|
|
|
| ---- | ---- | ---- |
|
|
|
|
|
| focus | 使 input 获取焦点 | - |
|