Skip to content

useRafFn

每个 requestAnimationFrame 上调用函数。具有暂停和恢复控制。

¥Call function on every requestAnimationFrame. With controls of pausing and resuming.

示例

Frames: 0
Delta: 0ms
FPS Limit: 60

用法

¥Usage

js
import { useRafFn } from '@vueuse/core'
import { shallowRef } from 'vue'

const count = shallowRef(0)

const { pause, resume } = useRafFn(() => {
  count.value++
  console.log(count.value)
})