Skip to content

useDebouncedRefHistory

带去抖滤波器的 useRefHistory 的简写。

¥Shorthand for useRefHistory with debounced filter.

示例

Count: 0
/
Delay (in ms):

History (limited to 10 records for demo)
2024-11-29 22:46:29{ 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 { ref } from 'vue'

const counter = ref(0)
const { history, undo, redo } = useDebouncedRefHistory(counter, { deep: true, debounce: 1000 })

类型声明

typescript
/**
 * Shorthand for [useRefHistory](https://vueuse.org/useRefHistory) with debounce filter.
 *
 * @see https://vueuse.org/useDebouncedRefHistory
 * @param source
 * @param options
 */
export declare function useDebouncedRefHistory<Raw, Serialized = Raw>(
  source: Ref<Raw>,
  options?: Omit<UseRefHistoryOptions<Raw, Serialized>, "eventFilter"> & {
    debounce?: MaybeRefOrGetter<number>
  },
): UseRefHistoryReturn<Raw, Serialized>

源代码

源代码示例文档

变更日志

No recent changes

VueUse 中文网 - 粤ICP备13048890号