跳到内容

useThrottledRefHistory

类别
导出大小
1.37 kB
最近更改
5 天前
相关

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

演示

计数: 0
/
延迟 (毫秒)

历史记录 (演示限制为 10 条记录)
2025-03-10 03:47:04{ 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 })

类型声明

typescript
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>

源代码

SourceDemoDocs

贡献者

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

更新日志

v12.8.0 于 2025/3/5
7432f - feat(types): 弃用 MaybeRefMaybeRefOrGetter,转而使用 Vue 的原生类型 (#4636)
v12.0.0-beta.1 于 2024/11/21
0a9ed - feat!: 删除 Vue 2 支持,优化包并清理代码 (#4349)
v10.7.0 于 2023/12/5
fccf2 - feat: 升级依赖 (#3614)

在 MIT 许可证下发布。