TimePicker 时间选择框

输入或选择时间的控件。

何时使用

当用户需要输入一个时间,可以点击标准输入框,弹出时间面板进行选择。

代码演示

12 小时制

12 小时制的时间选择器,默认的 format 为 h:mm:ss a

expand code expand code

附加内容

在 TimePicker 选择框底部显示自定义的内容。

expand code expand code

基本

点击 TimePicker,然后可以在浮层中选择或者输入某一时间。

expand code expand code

禁用

禁用时间选择。

expand code expand code

选择时分

TimePicker 浮层中的列会随着 format 变化,当略去 format 中的某部分时,浮层中对应的列也会消失。

expand code expand code

步长选项

可以使用 hourStep minuteStep secondStep 按步长展示可选的时分秒。

expand code expand code

三种大小

三种大小的输入框,大的用在表单中,中的为默认。

expand code expand code

use value and @change



v-model



Do not change

受控组件

value 和 onChange 需要配合使用。也可以直接使用v-model。

expand code expand code

后缀图标

点击 TimePicker,然后可以在浮层中选择或者输入某一时间。

expand code expand code

API

参数 说明 类型 默认值
addon 选择框底部显示自定义的内容 slot | slot-scope
allowEmpty 是否展示清除按钮 boolean true
autoFocus 自动获取焦点 boolean false
clearText 清除按钮的提示文案 string clear
defaultOpenValue 当 defaultValue/value 不存在时,可以设置面板打开时默认选中的值 moment moment()
defaultValue 默认时间 moment
disabled 禁用全部操作 boolean false
disabledHours 禁止选择部分小时选项 function()
disabledMinutes 禁止选择部分分钟选项 function(selectedHour)
disabledSeconds 禁止选择部分秒选项 function(selectedHour, selectedMinute)
format 展示的时间格式 string "HH:mm:ss"
getPopupContainer 定义浮层的容器,默认为 body 上新建 div function(trigger)
hideDisabledOptions 隐藏禁止选择的选项 boolean false
hourStep 小时选项间隔 number 1
inputReadOnly 设置输入框为只读(避免在移动设备上打开虚拟键盘) boolean false
minuteStep 分钟选项间隔 number 1
open(.sync) 面板是否打开 boolean false
placeholder 没有值的时候显示的内容 string "请选择时间"
popupClassName 弹出层类名 string ''
secondStep 秒选项间隔 number 1
suffixIcon 自定义的选择框后缀图标 string | VNode | slot -
use12Hours 使用 12 小时制,为 true 时 format 默认为 h:mm:ss a boolean false
value(v-model) 当前时间 moment

事件

事件名称 说明 回调参数
change 时间发生变化的回调 function(time: moment, timeString: string): void
openChange 面板打开/关闭时的回调 (open: boolean): void

方法

名称 描述
blur() 移除焦点
focus() 获取焦点
  Switch 开关Transfer 穿梭框