vue倒计时插件
vue2-countdown是一个无依赖项的轻量级vue组件,轻松实现倒计时需求,摆脱时间函数烦恼。 支持SSR。
yarn add @choujiaojiao/vue2-countdown
or
npm install @choujiaojiao/vue2-countdown
<template>
<Countdown :time="3666" format="hh:mm:ss" @on-end="onCountdownEnd">
<template slot-scope="{ time }">{{ time }}</template>
</Countdown>
</template>
<script>
import Countdown from '@choujiaojiao/vue2-countdown'
export default {
components: { Countdown },
methods: {
onCountdownEnd() {
console.log('countdown end~')
}
}
}
</script>
Property | Description | type | default |
---|---|---|---|
time | 倒计时时间差(单位:秒) | Number | 0 |
step | 多久执行一次倒计时(单位:秒) | Number | 1 |
switch | 倒计时开关 | Boolean | - - |
format | 格式化 | String | - - |
Function Name | Description |
---|---|
on-end | 倒计时结束回调 |
on-countdown | 每次倒计时回调 |
reCountdown | 重新倒计时( ex: this.$refs.countdown.reCountdown() ) |