refDebounced
Category
Export Size
423 B
Last Changed
15 minutes ago
Alias
useDebounce
debouncedRef
Related
对 ref 的更新进行防抖。
Demo
此演示设置了 1000ms 的延迟。
Debounced:
更新次数: 0
用法
js
import { refDebounced } from '@vueuse/core'
const input = ref('foo')
const debounced = refDebounced(input, 1000)
input.value = 'bar'
console.log(debounced.value) // 'foo'
await sleep(1100)
console.log(debounced.value) // 'bar'
你也可以传递一个可选的第三个参数,包括 maxWait
选项。详情请参阅 useDebounceFn
推荐阅读
类型声明
typescript
/**
* 对 ref 的更新进行防抖。
*
* @return 一个新的防抖 Ref
*/
export declare function refDebounced<T>(
value: Ref<T>,
ms?: MaybeRefOrGetter<number>,
options?: DebounceFilterOptions,
): Readonly<Ref<T>>
export { refDebounced as useDebounce, refDebounced as debouncedRef }
Source
贡献者
Anthony Fu
丶远方
Anthony Fu
Dominik Klein
变更日志
v10.0.0-beta.4
on 4/13/20234d757
- feat(types)!: rename MaybeComputedRef
to MaybeRefOrGetter