mounted () {
window.addEventListener('scroll', this.lazyLoading); // 滚动到底部,再加载的处理事件
},
beforeDestroy () {
window.removeEventListener('scroll', this.lazyLoading); //离开页面时移除
},
methods:{
lazyLoading () { // 滚动到底部,再加载的处理事件
let scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
let clientHeight = document.documentElement.clientHeight;
let scrollHeight = document.documentElement.scrollHeight;
if (scrollTop + clientHeight >= scrollHeight) { // 如果滚动到接近底部,自动加载下一页
//事件处理
},
}