Skip to content

useThrottleFn

useThrottleFn(fn, wait?, options?): UseThrottleFnWithLockResult

使用节流函数实现的 Vue Hook,用于在组件中创建一个经过节流处理的函数。

参数

NameTypeDefault valueDescription
fnFunctionundefined要执行的函数。
wait?number3000节流等待的毫秒数,在该时间间隔内只会执行一次函数。
options?anyundefined节流配置选项。

返回值

UseThrottleFnWithLockResult

  • 一个包含运行函数、取消、立即执行和判断是否运行中的对象。

Throws

如果传入的 fn 不是一个函数,则抛出 TypeError。

源码

use-throttle-fn.js