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; } }
网友评论