Skip to content

useCountDown 倒计时钩子

用于实现倒计时功能的 Vue 钩子函数。

基本用法

ts
import { useCountdown } from '@minilo/utils'

const { remaining, isRunning, formattedTime, start, stop, reset } = useCountdown(60) // 60秒倒计时

// 启动倒计时
start()

// 暂停倒计时
stop()

// 重置倒计时
reset()

参数

参数说明类型默认值必填
seconds倒计时时长(秒)number-

返回值

属性说明类型
remaining剩余秒数Ref<number>
isRunning倒计时是否正在运行Ref<boolean>
formattedTime格式化后的时间字符串ComputedRef<string>
start启动倒计时的方法() => void
stop暂停倒计时的方法() => void
reset重置倒计时的方法(newSeconds?: number) => void