Skip to content

TimePicker 时间选择器

AuTimePicker 用于选择本地时、分、秒。浮层内的值先作为草稿编辑,点击“确定”后才更新模型,避免滚动或键盘操作产生中间提交。

时间面板仅在点击输入控件,或聚焦后按方向键时打开;单纯通过 Tab 聚焦不会自动展开。

基础用法

时间边界与步长

可限制可用时间范围,并分别控制小时、分钟和秒的选项步长。

当前时间:09:30:00;短格式:14:45

vue
<template>
  <div class="time-picker-demo">
    <label>
      <span>提醒时间</span>
      <AuTimePicker
        v-model="time"
        min-time="08:30:00"
        max-time="20:00:00"
        :minute-step="5"
      />
    </label>
    <label>
      <span>不显示秒</span>
      <AuTimePicker v-model="shortTime" :show-seconds="false" :minute-step="15" />
    </label>
    <p>当前时间:{{ time }};短格式:{{ shortTime }}</p>
  </div>
</template>
<script setup>
import { ref } from 'vue';
import { AuTimePicker } from 'aurora-plus';
const time = ref('09:30:00');
const shortTime = ref('14:45');
</script>
<style scoped>
.time-picker-demo {
  display: grid;
  width: min(100%, 460px);
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}
.time-picker-demo label {
  display: grid;
  gap: 6px;
  color: var(--au-color-text-secondary);
  font-size: var(--au-font-size-small);
}
.time-picker-demo p {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--au-color-text-secondary);
  font-size: var(--au-font-size-small);
}
</style>

Attributes

属性说明类型默认值
modelValue当前时间string / Date / number''
valueType输出类型auto / string / date / timestampauto
valueFormat字符串模型格式stringshowSeconds
displayFormat显示与手动输入格式stringshowSeconds
showSeconds是否显示秒booleantrue
hourStep / minuteStep / secondStep各时间单位步长number1
minTime / maxTime时间边界string / Date / numbernull
disabledTime禁用函数(date) => booleannull
size尺寸small / default / largedefault
placeholder占位文字string选择时间
disabled / readonly禁用 / 只读booleanfalse
editable / clearable可输入 / 可清空;有值时清除按钮原位替换时间图标booleantrue
invalid外部错误状态booleanfalse
placement浮层方位stringbottom-start
teleported / appendTo / zIndex浮层挂载与层级boolean / string | Element / numbertrue / body / 1200
ariaLabel控件无障碍名称string选择时间

默认完整格式为 HH:mm:ss,隐藏秒后为 HH:mm。字符串模型使用本地时间语义;传入 Date 时会保留其日期部分并更新时间部分。

Events

事件名说明参数
update:modelValue确认后的值更新(value)
change有效时间提交(value, date, event)
clear清空(event)
focus / blur输入框焦点变化(event)
visible-change浮层显隐变化(visible)
invalid-input输入无法解析或不可用(text, event)

Exposes

focus(options?)blur()open()close(reason?),以及 inputRefpopoverRef

Aurora Plus · Vue 3 Component Library