From 055166551d78f8abfb9d05615a0aabe9234cf2c7 Mon Sep 17 00:00:00 2001 From: hzj <1304805162@qq.com> Date: Mon, 9 Mar 2026 17:56:35 +0800 Subject: [PATCH] =?UTF-8?q?chore(=E9=98=B2=E6=8A=96=E8=8A=82=E6=B5=81?= =?UTF-8?q?=E5=B7=A5=E5=85=B7):=20=E6=96=B0=E5=A2=9E=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/useDebounce.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/utils/useDebounce.js b/src/utils/useDebounce.js index 237e21d..17494ac 100644 --- a/src/utils/useDebounce.js +++ b/src/utils/useDebounce.js @@ -6,6 +6,7 @@ export function useDebounce(fn, delay = 500, immediate = false) { let instance = getCurrentInstance() // 获取当前组件实例 const debounced = (...args) => { + // 接收所有传入的参数 if (timer) clearTimeout(timer) if (immediate && !timer) { @@ -14,7 +15,7 @@ export function useDebounce(fn, delay = 500, immediate = false) { } timer = setTimeout(() => { - if (!immediate) fn.apply(this, args) + if (!immediate) fn.apply(this, args) // 将参数透传给原始函数 timer = null // 清理timer引用 }, delay) } @@ -50,7 +51,7 @@ export function useThrottle(fn, delay = 1000) { const now = Date.now() if (now - lastCall < delay) return lastCall = now - fn(...args) + fn(...args) // 将参数透传给原始函数 } return throttled