本文最后更新于 2023-03-30 04:53
useThrottleFn
函数节流(点击查看官方文档)
参数
参数 | 说明 | 默认值 |
---|---|---|
fn | 需要节流的函数 | - |
ms? | 等待时间,单位为毫秒 | 200 |
leading? | 是否在延迟开始前调用函数 | true |
trailing? | 是否在延迟开始后调用函数 | false |
类型声明
export declare function useThrottleFn<T extends FunctionArgs>(
fn: T,
ms?: MaybeComputedRef<number>,
trailing?: boolean,
leading?: boolean
): T;
代码演示
let onDemo = useThrottleFn(() => {
// 此处执行节流操作
}, 2000);
本文系作者 @SniperXu 原创发布在锋旭。未经许可,禁止转载。