!104 fix backTop 返回顶部 无法生效
Merge pull request !104 from pplokijuhyg/N/A
This commit is contained in:
commit
38e5c90630
@ -174,7 +174,7 @@ const getScrollParent = (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// @ts-ignore
|
// @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(() => {
|
onMounted(() => {
|
||||||
if (!props.target) return;
|
if (!props.target) return;
|
||||||
scrollTarget.value = getScrollTarget();
|
scrollTarget.value = getScrollTarget();
|
||||||
scrollTarget.value.addEventListener("scroll", throttle(handleScroll, 300));
|
scrollTarget.value.addEventListener("scroll", callback);
|
||||||
});
|
});
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
scrollTarget.value?.removeEventListener(
|
scrollTarget.value?.removeEventListener(
|
||||||
"scroll",
|
"scroll",
|
||||||
throttle(handleScroll, 300)
|
callback
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
Reference in New Issue
Block a user