Skip to content
12:13

TnCountDown-倒计时 ​

该组件一般使用于某个活动的截止时间上,通过数字的变化,给用户明确的时间感受,提示用户进行某一个行为操作

组件位置 ​

typescript
import TnCountDown from '@tuniao/tnui-vue3-uniapp/components/count-down/src/count-down.vue'
import TnCountDown from '@tuniao/tnui-vue3-uniapp/components/count-down/src/count-down.vue'
typescript
import TnCountDown from '@/uni_modules/tuniaoui-vue3/components/count-down/src/count-down.vue'
import TnCountDown from '@/uni_modules/tuniaoui-vue3/components/count-down/src/count-down.vue'

平台差异说明 ​

App(vue)H5微信小程序支付宝小程序...
√√√√适配中

基础使用 ​

  • 通过time属性设置倒计时的时间,单位为秒
vue
<template>
  <TnCountDown :time="300" />
</template>
<template>
  <TnCountDown :time="300" />
</template>

控制时间显示、隐藏 ​

通过设置show-day、show-hour、show-minute、show-second属性,控制显示、隐藏 天、时、分、秒,默认只显示时、分、秒

针对day的显示还有auto-hide-day属性,当time小于86400时,自动隐藏day,默认为true

显示天、时、分、秒 ​

vue
<template>
  <TnCountDown :time="86500" show-day />
</template>
<template>
  <TnCountDown :time="86500" show-day />
</template>

显示分、秒 ​

vue
<template>
  <TnCountDown :time="300" :show-hour="false" />
</template>
<template>
  <TnCountDown :time="300" :show-hour="false" />
</template>

修改分割符样式 ​

通过separator-mode属性,默认为en,可选值为en、cn,分别对应英文分割符和中文分割符

vue
<template>
  <TnCountDown :time="300" separator-mode="cn" />
</template>
<template>
  <TnCountDown :time="300" separator-mode="cn" />
</template>

API ​

Props ​

属性名说明类型默认值可选值
time倒计时时间,单位 秒Number0-
auto-start是否自动开始Booleantruefalse
size倒计时尺寸,内置 sm 、lg 、xl,也可以传递指定的数值进行设置String-sm \ lg \ xl
text-color字体颜色,支持图鸟内置的颜色值、hex、rgb、rgbaString--
show-day是否显示天数Booleanfalsetrue
show-hour是否显示小时Booleantruefalse
show-minute是否显示分钟Booleantruefalse
show-second是否显示秒数Booleantruefalse
auto-hide-day自动隐藏天数Booleantruefalse
separator-mode分割符类型,cn 显示 对应语言的中文分割符,en 显示 : 分割符Stringencn
separator-color分割符颜色,支持图鸟内置的颜色值、hex、rgb、rgbaString--
border是否显示边框Booleanfalsetrue
border-color边框颜色,支持图鸟内置的颜色值、hex、rgb、rgbaString--

Emits ​

事件名说明类型
start倒计时开始时触发() => void
end倒计时结束时触发() => void

Expose ​

函数名说明类型
start开始倒计时() => void
stop停止倒计时() => void
reset重置倒计时() => void