useIntervalFn
带有控制功能的 setInterval
包装器
示例
使用方法
js
import { useIntervalFn } from '@vueuse/core'
const { pause, resume, isActive } = useIntervalFn(() => {
/* 你的函数 */
}, 1000)
类型声明
typescript
export interface UseIntervalFnOptions {
/**
* 立即开始计时器
*
* @default true
*/
immediate?: boolean
/**
* 在调用 `resume` 之后立即执行回调
*
* @default false
*/
immediateCallback?: boolean
}
/**
* 带有控制功能的 `setInterval` 包装器
*
* @param cb
* @param interval
* @param options
*/
export declare function useIntervalFn(
cb: Fn,
interval?: MaybeRefOrGetter<number>,
options?: UseIntervalFnOptions,
): Pausable
源码
贡献者
Anthony Fu
一纸忘忧
Jelf
Anthony Fu
Börge Kiss
Dan Rose
sun0day
Enzo Innocenzi
wwj
Matvey Melishev
meteorlxy
Aurélio A. Heckert
xuxuhahaha
Hogne Vevle
Daiki Ojima
更新日志
v10.0.0-beta.5
on 4/13/2023cb644
- refactor!: remove isFunction
and isString
utilsv10.0.0-beta.4
on 4/13/20234d757
- feat(types)!: rename MaybeComputedRef
to MaybeRefOrGetter
0a72b
- feat(toValue): rename resolveUnref
to toValue
v9.12.0
on 1/29/2023v9.7.0
on 12/16/2022