Options
All
  • Public
  • Public/Protected
  • All
Menu

Module vx-hooks/useThrottle

节流值

Index

Interfaces

Functions

Functions

useThrottle

  • useThrottle<T>(watchFn: (() => T) | Ref<T> | ComputedRef<T>, wait?: number): UseThrottleAPI<T>
  • 节流值

    summary

    使用节流函数更新对应响应值, 时间间隔将小于配置时间 时间间隔 => 等待时间 - 0.01s

    example
    
    const watchVal = ref(0)
    const { state } = useThrottle(watchVal, 2)
    
    watchval.value = 1
    // dely 1
    watchval.value = 2
    watchval.value = 3
    watchval.value = 4
    // dely 1
    console.log(state.value)
    => 1
    
    

    Type parameters

    • T

      监听值类型

    Parameters

    • watchFn: (() => T) | Ref<T> | ComputedRef<T>

      监听对象

    • wait: number = 1

      延时时常(s)

    Returns UseThrottleAPI<T>

Generated using TypeDoc