From 4caef2eb5d1c528ecef8ec752bfc60038d7a0708 Mon Sep 17 00:00:00 2001 From: pplokijuhyg <1162963624@qq.com> Date: Fri, 11 Nov 2022 08:54:19 +0000 Subject: [PATCH] =?UTF-8?q?fix=20backTop=20=E8=BF=94=E5=9B=9E=E9=A1=B6?= =?UTF-8?q?=E9=83=A8=20=E6=97=A0=E6=B3=95=E7=94=9F=E6=95=88=20=E5=AE=9E?= =?UTF-8?q?=E6=B5=8B=20document.documentElement=20document.body=20=20?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E8=A7=A6=E5=8F=91=E6=BB=9A=E5=8A=A8=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6=20=20removeEventListener=20=E9=9C=80=E8=A6=81?= =?UTF-8?q?=E4=BD=BF=E7=94=A8addEventListener=20=E7=9B=B8=E5=90=8C?= =?UTF-8?q?=E7=9A=84=E5=87=BD=E6=95=B0(=E5=BC=95=E7=94=A8=E5=9C=B0?= =?UTF-8?q?=E5=9D=80)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: pplokijuhyg <1162963624@qq.com> --- package/component/src/component/backTop/index.vue | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package/component/src/component/backTop/index.vue b/package/component/src/component/backTop/index.vue index c73b2832..97a870c2 100644 --- a/package/component/src/component/backTop/index.vue +++ b/package/component/src/component/backTop/index.vue @@ -174,7 +174,7 @@ const getScrollParent = ( } } // @ts-ignore - return document.documentElement || document.body || window; + return window; }; // 节流 @@ -189,17 +189,17 @@ const throttle = (func: Function, wait: number) => { } }; }; - +const callback = throttle(handleScroll, 300); onMounted(() => { if (!props.target) return; scrollTarget.value = getScrollTarget(); - scrollTarget.value.addEventListener("scroll", throttle(handleScroll, 300)); + scrollTarget.value.addEventListener("scroll", callback); }); onBeforeUnmount(() => { scrollTarget.value?.removeEventListener( "scroll", - throttle(handleScroll, 300) + callback ); });