From 39c8282cc83ef3d453bcb90232805fb7321846cd Mon Sep 17 00:00:00 2001 From: hongxilin <17663930442@163.com> Date: Thu, 2 Jan 2025 11:16:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=B4=BB=E5=8A=A8=E4=BF=9D?= =?UTF-8?q?=E8=AF=81=E5=A4=9A=E6=AC=A1=E7=82=B9=E5=87=BB=E5=8F=AA=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E4=B8=80=E6=AC=A1=EF=BC=88=E4=BF=AE=E6=94=B9=E7=89=88?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vue/gold-system/src/views/managerecharge/activity.vue | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/vue/gold-system/src/views/managerecharge/activity.vue b/vue/gold-system/src/views/managerecharge/activity.vue index 423e2db..9156d73 100644 --- a/vue/gold-system/src/views/managerecharge/activity.vue +++ b/vue/gold-system/src/views/managerecharge/activity.vue @@ -166,7 +166,21 @@ const add = async function () { } }); }; -const throttledAdd = _.throttle(add, 5000); +// 使用 _.throttle 并设置 trailing 为 false 实现严格节流,只执行一次 +const throttledAdd = _.throttle(add, 5000, { trailing: false }); +// 新增一个标志,用于控制是否执行函数 +// let onceFunction = true; +// 改进后的手动节流函数 +// const throttledAdd = (...args) => { +// if (onceFunction) { +// add.apply(null, args); +// onceFunction = false; // 执行后设置为false,表示不能再执行了 +// timer = setTimeout(() => { +// onceFunction = true; // 间隔结束后,恢复为可以执行的状态,但需要新的点击触发 +// timer = null; +// }, 1000); // 设置节流时间间隔为1000毫秒(1秒),可调整 +// } +// }; // 删除========================================================= // 删除按钮 const del = function (row) { @@ -512,7 +526,7 @@ onMounted(async function () {