Skip to content

useIntervalFn

Category
Export Size
368 B
Last Changed
3 hours ago

带有控制功能的 setInterval 包装器

Demo

Hello

间隔:

使用方法

js
import { useIntervalFn } from '@vueuse/core'

const { pause, resume, isActive } = useIntervalFn(() => {
  /* 你的函数 */
}, 1000)

Type Declarations

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

Source

SourceDemoDocs

Contributors

jorshen

Changelog

No recent changes

Released under the MIT License.