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 ); });