vue实时监听页面滑动,获取top值

vue实时监听页面滑动,获取top值


mounted() {
window.addEventListener(“scroll”, this.scroll);
},
methods: {
scroll() {
let scrollTop =
window.pageYOffset ||
document.documentElement.scrollTop ||
document.body.scrollTop;
if (scrollTop / 11 > 27.5) {
this.isNav = true;
}else{
this.isNav=false;
}
},
}

你可能感兴趣的:(监听页面滑动,实时获取top值)