vue 写一个方法然后在生命周期里调用
mounted() {
this.top();
},
methods: {
top() {
window.onscroll = function() {
let scrollT =
document.documentElement.scrollTop || document.body.scrollTop;
let scrollH =
document.documentElement.scrollHeight || document.body.scrollHeight;
let clientH =
document.documentElement.clientHeight || document.body.clientHeight;
if (scrollT > 50) {
document.getElementsByClassName('footAdvertising')[0].style.display = "block"
console.log("大于这个高度,广告出现")
}
if (scrollT == scrollH - clientH) {
console.log("已到达页面底部")
} else if (scrollT => 50) {
document.getElementsByClassName('footAdvertising')[0].style.display = "none"
console.log("小于这个高度广告消失")
}
};
}```
}