主题
useIntervalFn
带控件的 setInterval
封装
¥Wrapper for setInterval
with controls
示例
用法
¥Usage
js
import { useIntervalFn } from '@vueuse/core'
const { pause, resume, isActive } = useIntervalFn(() => {
/* your function */
}, 1000)
类型声明
typescript
export interface UseIntervalFnOptions {
/**
* Start the timer immediately
*
* @default true
*/
immediate?: boolean
/**
* Execute the callback immediately after calling `resume`
*
* @default false
*/
immediateCallback?: boolean
}
/**
* Wrapper for `setInterval` with controls
*
* @param cb
* @param interval
* @param options
*/
export declare function useIntervalFn(
cb: Fn,
interval?: MaybeRefOrGetter<number>,
options?: UseIntervalFnOptions,
): Pausable