配合js做监听
const scrollListener = () => {
const topHeight = getScrollTop();
if (topHeight === 0) {
scrollIsTop.value = true;
} else {
scrollIsTop.value = false;
}
scrollLeft.value =
Math.max(document.body.scrollLeft, document.documentElement.scrollLeft) +
"px";
};
onMounted(() => {
window.addEventListener("scroll", scrollListener);
});
onUnmounted(() => {
window.removeEventListener("scroll", scrollListener);
});
scrollListener();