时间选择器

基础用法

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

  • 示例:
点击查看代码
<template>
  <a-space direction="vertical">
    <z-time-picker v-model:value="value" />
    <z-time-picker v-model:value="strValue" value-format="HH:mm:ss" />
  </a-space>
</template>
<script>
import dayjs from 'dayjs';
import { defineComponent, ref, watch } from 'vue';
export default defineComponent({
  setup() {
    const value = ref(dayjs('08:00:00', 'HH:mm:ss'));
    const strValue = ref('09:00:00');
    watch(value, () => {
      console.log(value.value);
    });
    watch(strValue, () => {
      console.log(strValue.value);
    });
    return {
      value,
      strValue,
    };
  },

});
</script>

范围选择器

  • 示例:
点击查看代码
<template>
  <a-space direction="vertical">
    <a-time-range-picker :bordered="false" />
  </a-space>
</template>

参数

参数说明类型默认值
allowClear是否展示清除按钮booleantrue
autofocus自动获取焦点booleanfalse
bordered是否有边框booleantrue
clearIcon自定义的清除图标slot
clearText清除按钮的提示文案stringclear
disabled禁用全部操作booleanfalse
disabledHours禁止选择部分小时选项function()
disabledMinutes禁止选择部分分钟选项function(selectedHour)
disabledSecond禁止选择部分秒选项function(selectedHour, selectedMinute)
format展示的时间格式stringHH:mm:ss
getPopupContainer定义浮层的容器,默认为 body 上新建 divfunction(trigger)
hideDisabledOptions隐藏禁止选择的选项booleanfalse
hourStep小时选项间隔number1
inputReadOnly设置输入框为只读(避免在移动设备上打开虚拟键盘)booleanfalse
minuteStep分钟选项间隔number1
open(v-model)面板是否打开booleanfalse
placeholder没有值的时候显示的内容string | [string, string]请选择时间
popupClassName弹出层类名string
popupStyle弹出层样式对象object
renderExtraFooter选择框底部显示自定义的内容slot
secondStep秒选项间隔number1
showNow面板是否显示“此刻”按钮boolean
suffixIcon自定义的选择框后缀图标slot
use12Hours使用 12 小时制,为 true 时 format 默认为 h:mm:ss abooleanfalse
value(v-model)当前时间booleandayjs
valueFormat可选,绑定值的格式,对 value、defaultValue 起作用。不指定则绑定值为 dayjs 对象string
Last Updated:
Contributors: jixuanyu