vue无感上拉加载更多

window.addEventListener('scroll',this.onScroll);


onScroll() {//可滚动容器的高度letinnerHeight =document.querySelector('#app').clientHeight;//屏幕尺寸高度letouterHeight =document.documentElement.clientHeight;//可滚动容器超出当前窗口显示范围的高度letscrollTop =document.documentElement.scrollTop;//scrollTop在页面为滚动时为0,开始滚动后,慢慢增加,滚动到页面底部时,出现innerHeight < (outerHeight + scrollTop)的情况,严格来讲,是接近底部。console.log(innerHeight +" "+ outerHeight +" "+ scrollTop);if(innerHeight < (outerHeight + scrollTop)) {//加载更多操作console.log("loadmore");this.items +=10; } }



4329096-e2f48cb6412943cd.png

转载于:https://www.jianshu.com/p/0e1b88f3b7bb

猜你喜欢

转载自blog.csdn.net/weixin_34307464/article/details/91151347