# ui-time 时间显示组件

版本:v2.3.11

时间显示组件用于格式化和显示时间,支持多种时间格式和相对时间显示

# 基本使用

<template>
  <div class="time-demo">
    <ui-time :time="new Date()" format="YYYY-MM-DD HH:mm:ss" />
    <ui-time :time="new Date(Date.now() - 3600000)" relative />
  </div>
</template>

<style scoped>
.time-demo {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
</style>

# Props

参数 类型 默认值 说明
time Date/String/Number new Date() 时间值,支持 Date 对象、时间字符串或时间戳
format String 'YYYY-MM-DD' 时间格式,使dayjs 格式语法
relative Boolean false 是否显示相对时间,如 "1小时
refresh Boolean false 是否自动刷新相对时间
refreshInterval Number 60000 自动刷新间隔,单位:ms

# Events

事件 说明 回调参数
click 点击时间文本时触 -

# Slots

名称 说明
default 自定义时间显示内

在线演示

扫码或点击链接在手机上查看完整演示

https://shadow-ui3-demo.nooko.cn/#/pages/functional/time/time