Skip to content

watchOnce

使用 { once: true } 观察值的简写。回调触发一次后,监视器将停止。有关完整详细信息,请参阅 Vue 文档

¥Shorthand for watching value with { once: true }. Once the callback fires once, the watcher will be stopped. See Vue's docs for full details.

用法

¥Usage

watch 类似,但与 { once: true } 相同

¥Similar to watch, but with { once: true }

ts
import { watchOnce } from '@vueuse/core'

watchOnce(source, () => {
  // triggers only once
  console.log('source changed!')
})