Skip to content

useIntervalFn

Category
Export Size
341 B
Last Changed
last year

带有控制功能的 setInterval 包装器

Demo

Yo!

间隔:

使用方法

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

Source

SourceDemoDocs

贡献者

Anthony Fu
丶远方
Jelf
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)

Released under the MIT License.

Build faster with AI
New Masterclass to help you leverage AI in your Vue workflow.
Get Early Access