data() {
return {
top: 0, // 页面滚动高度
};
},
//挂载时添加监听事件
mounted() {
window.addEventListener("scroll", this.scrollHandle); //绑定页面滚动事件
//mouseover click 等其他事件也可
},
methods:{
// 获取页面滚动高度
scrollHandle(e) {
this.top = e.srcElement.scrollingElement.scrollTop; // 获取页面滚动高度
},
}
watch: {
top(v) {
if (v > 10) {
this.isOver = true;
}
if (v == 0) {
this.isOver = false;
}
},
},
监听页面滚动高度
最新推荐文章于 2024-03-26 18:57:06 发布