监听滚轴高度

mounted() {
this.getClassify()
window.addEventListener('scroll', this.handleScroll, true);
},
methods: {
//检测滚轴
handleScroll () {
let clientHeight = document.documentElement.clientHeight || document.body.clientHeight;
// 设备/屏幕高度
let scrollObj = document.getElementById("picup"); // 滚动区域 最外层ID
let scrollTop = scrollObj.scrollTop; // div 到头部的距离
console.log(scrollObj.scrollTop)
//滚动条到底部的条件
if(scrollObj.scrollTop>=459){
this.tabUl = true
}
if(scrollObj.scrollTop<459){
this.tabUl = false
}
},
},

destroyed () {
window.removeEventListener('scroll', this.handleScroll); // 离开页面清除(移除)滚轮滚动事件
},

注:本页最外层的div添加id

原文地址:https://www.cnblogs.com/PoisonousMushrooms/p/13958758.html