watchThrottled 
throttleされたwatch。
デモ 
このデモでは、遅延は1000ミリ秒に設定されています。
入力
更新回数: 0
使用方法 
watchと似ていますが、コールバック関数に適用される追加オプション throttle が提供されます。
ts
import { watchThrottled } from '@vueuse/core'
watchThrottled(
  source,
  () => { console.log('changed!') },
  { throttle: 500 },
)これは本質的に次のコードの省略形です
ts
import { throttleFilter, watchWithFilter } from '@vueuse/core'
watchWithFilter(
  source,
  () => { console.log('changed!') },
  {
    eventFilter: throttleFilter(500),
  },
)型宣言 
型宣言を表示
typescript
export interface WatchThrottledOptions<Immediate>
  extends WatchOptions<Immediate> {
  throttle?: MaybeRefOrGetter<number>
  trailing?: boolean
  leading?: boolean
}
export declare function watchThrottled<
  T extends Readonly<WatchSource<unknown>[]>,
  Immediate extends Readonly<boolean> = false,
>(
  sources: [...T],
  cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>,
  options?: WatchThrottledOptions<Immediate>,
): WatchStopHandle
export declare function watchThrottled<
  T,
  Immediate extends Readonly<boolean> = false,
>(
  source: WatchSource<T>,
  cb: WatchCallback<T, Immediate extends true ? T | undefined : T>,
  options?: WatchThrottledOptions<Immediate>,
): WatchStopHandle
export declare function watchThrottled<
  T extends object,
  Immediate extends Readonly<boolean> = false,
>(
  source: T,
  cb: WatchCallback<T, Immediate extends true ? T | undefined : T>,
  options?: WatchThrottledOptions<Immediate>,
): WatchStopHandle
export { watchThrottled as throttledWatch }ソース 
貢献者 
変更履歴 
v12.0.0-beta.1 2024/11/21v10.0.0-beta.4 2023/4/134d757 - feat(types)!:  MaybeComputedRef から MaybeRefOrGetter に名前変更