Skip to content

watchAtMost

类别
导出大小
339 B
最近修改
2 days ago

watch 触发的次数。

用法

🌐 Usage

类似于 watch,但增加了一个选项 count,用于设置回调函数触发的次数。达到次数后,观察将自动停止。

🌐 Similar to watch with an extra option count which set up the number of times the callback function is triggered. After the count is reached, the watch will be stopped automatically.

ts
import { 
watchAtMost
} from '@vueuse/core'
watchAtMost
(
source, () => {
console
.
log
('trigger!') }, // triggered it at most 3 times
{
count
: 3, // the number of times triggered
}, )