Skip to content

useDebouncedRefHistory

类别
导出大小
1.38 kB
最近修改
2 days ago
相关

useRefHistory 的带防抖滤波器的速记方式。

🌐 Shorthand for useRefHistory with debounced filter.

示例

Count: 0
/
Delay (in ms):

History (limited to 10 records for demo)
2026-02-08 18:48:02{ value: 0 }

用法

🌐 Usage

当计数器的值开始变化 1000 毫秒后,此函数会拍摄计数器的快照。

🌐 This function takes a snapshot of your counter after 1000ms when the value of it starts to change.

ts
import { 
useDebouncedRefHistory
} from '@vueuse/core'
import {
shallowRef
} from 'vue'
const
counter
=
shallowRef
(0)
const {
history
,
undo
,
redo
} =
useDebouncedRefHistory
(
counter
, {
deep
: true,
debounce
: 1000 })