在移动端滚动加载时,因为最开始用的Window.onscroll
导致在不同手机滚动效果不同(分辨率大的滚动加载没有效果,分辨率小的滚动重复加载)
mounted() {
window.addEventListener('scroll', this.lazyLoading); // 滚动到底部,再加载的处理事件
}
beforeDestroy () {
window.removeEventListener('scroll', this.lazyLoading); //离开页面时移除
},
methods: {
const self = this
const scrollTop = $(window).scrollTop();
const scrollHeight = $(document).height();
const windowHeight = $(window).height();
this.scrollHeight=scrollHeight;
if(scrollHeight-(scrollTop + windowHeight)<80) {
//判断数据
if (self.articles.length >= 1) {
self.busy = false;
//pageBool防止重复请求,在loadArticlesItem功能中设置为true
if(self.pageBool){
self.pageBool=false
//请求事件
self.loadArticlesItem(1);
}
} else {
}
}
},
}