Skip to content

useThrottledRefHistory

类别
导出体积
1.47 kB
上次更改
6 months ago
相关

带有节流过滤器的 useRefHistory 的简写。

示例

计数:0
/
延迟时间(毫秒):

历史记录(为演示目的限制为10条记录)
2025-09-09 10:42:48{ value: 0 }

用法

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

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
>
/** * 带节流功能的 useRefHistory 的简写。 * * @see https://vueuse.org/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

更新日志

7432f - feat(types): deprecate MaybeRef and MaybeRefOrGetter in favor of Vue's native (#4636)
0a9ed - feat!: drop Vue 2 support, optimize bundles and clean up (#4349)
fccf2 - feat: upgrade deps (#3614)