Skip to content

t-text-time

TextTime 时间文本

组件介绍

t-text-time 是用于格式化显示时间(秒数转换)的文本组件,支持将秒数转换为天、时、分、秒的格式显示,适用于倒计时、活动剩余时间等场景。

平台兼容

HarmonyH5AndroidiOS小程序UTS

基础用法

基础用法参考 demo/text-time/text-time.uvue

vue
<template>
  <view class="text-time-demo">
    <!-- 默认格式 -->
    <t-text-time text="3661"></t-text-time>
    
    <!-- 自定义格式 -->
    <t-text-time text="3661" format="h时M分s秒"></t-text-time>
    
    <!-- 仅显示分钟和秒 -->
    <t-text-time text="3661" format="M分s秒"></t-text-time>
    
    <!-- 完整格式 -->
    <t-text-time text="90061" format="d天h时M分s秒"></t-text-time>
  </view>
</template>

<style scoped>
.text-time-demo {
  padding: 40rpx;
}
</style>

Props

属性名说明类型默认值
text需要格式化的秒数string | number''
format时间格式化格式string'd天h时M分s秒'
path点击组件后跳转的页面路径;为空时仅响应事件string''
hover是否启用点击效果booleantrue
type组件主题类型,可选 infoprimaryerrorwarningsuccessstring''
disabled是否禁用booleanfalse
effect组件显示主题,可选 normaldarklightplainstring''
size组件尺寸,可选 largemediumsmallministring'medium'

时间格式说明

占位符说明示例(3661秒)
d天数0
h小时数1
M分钟数1
s秒数1

Events

事件名说明回调参数
click点击时触发event
initFinished组件初始化完成触发组件节点信息
touchstart触摸开始时触发event
touchend触摸结束时触发event
touchmove触摸移动时触发event
touchcancel触摸取消时触发event