Skip to content

Countdown 倒计时

倒计时组件,支持天/时/分/秒和自定义格式。

基础用法

vue
<template>
  <!-- 30 分钟倒计时 -->
  <parrot-countdown :time="1800000" />
</template>

自定义格式

vue
<parrot-countdown :time="86400000" format="DD天 HH时mm分ss秒" />

手动控制

vue
<parrot-countdown ref="cd" :time="60000" :auto-start="false" />
<parrot-button @click="$refs.cd.start()">开始</parrot-button>

API

Props

属性类型默认值说明
timenumber0倒计时时长(ms)
formatstring'HH:mm:ss'格式:DD/HH/mm/ss
autoStartbooleantrue自动开始

Events

事件说明
finish倒计时结束
change每秒触发

Methods

方法说明
start()开始倒计时
stop()暂停倒计时

Released under the MIT License.