Skip to content

useIntervalFn

类别
导出体积
341 B
上次更改
3 minutes ago

带有控制功能的 setInterval 包装器

示例

Hello

间隔:

使用方法

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/2023
cb644 - refactor!: remove isFunction and isString utils
v10.0.0-beta.4 on 4/13/2023
4d757 - feat(types)!: rename MaybeComputedRef to MaybeRefOrGetter
0a72b - feat(toValue): rename resolveUnref to toValue
v9.12.0 on 1/29/2023
39183 - feat(useRafFn, useIntervalFn, useTimeoutFn): make status readonly (#2685)
v9.7.0 on 12/16/2022
8bb7b - fix: watch computed refs instead of just refs (#2539)