跳到主要内容

useThrottledRefHistory

分类
导出大小
1.47 kB
上次更改
8 个月前
相关

带节流过滤器的 useRefHistory 简写。

演示

计数:0
/
延迟 (毫秒)

历史记录 (演示限制为 10 条)
2025-10-23 06:49:09{ value: 0 }

用法

此函数在计数器值更改后立即获取第一个快照,并在 1000 毫秒延迟后获取第二个快照。

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

类型声明

ts
export type 
UseThrottledRefHistoryOptions
<
Raw
,
Serialized
=
Raw
> =
Omit
<
UseRefHistoryOptions
<
Raw
,
Serialized
>,
"eventFilter" > & {
throttle
?:
MaybeRef
<number>
trailing
?: boolean
} export type
UseThrottledRefHistoryReturn
<
Raw
,
Serialized
=
Raw
,
> =
UseRefHistoryReturn
<
Raw
,
Serialized
>
/** * Shorthand for [useRefHistory](https://vueuse.org.cn/useRefHistory) with throttled filter. * * @see https://vueuse.org.cn/useThrottledRefHistory * @param source * @param options */ export declare function
useThrottledRefHistory
<
Raw
,
Serialized
=
Raw
>(
source
:
Ref
<
Raw
>,
options
?:
UseThrottledRefHistoryOptions
<
Raw
,
Serialized
>,
):
UseThrottledRefHistoryReturn
<
Raw
,
Serialized
>

来源

源码演示文档

贡献者

Anthony Fu
Roman Harmyder
IlyaL
Anthony Fu
Robin
OrbisK
Jelf
Bodo Graumann
wheat

更新日志

v12.8.0
7432f - feat(types): 废弃 MaybeRefMaybeRefOrGetter,转而使用 Vue 的原生类型 (#4636)
0a9ed - feat!: 放弃对 Vue 2 的支持,优化打包并清理 (#4349)
v10.7.0
fccf2 - feat: 升级依赖 (#3614)

根据 MIT 许可证发布。