首页 > 其他 > 详细

页面滚动到底部加载更多分页

时间:2020-09-25 09:43:52      阅读:47      评论:0      收藏:0      [点我收藏+]

// 通常写法
window.onscroll = function (e) { /* 判断是否滚到最下面 */ /* 如果已经滚到最下面则执行某个操作 */ var e =e || window.event; // 为了兼容谷歌和火狐 document.body.scrollTop是谷歌上的 /* 滚动条的垂直位置 */ var scrolltop = document.documentElement.scrollTop||document.body.scrollTop; /* 整个页面的正文高度 */ var scrollHeight = document.documentElement.scrollHeight||document.body.scrollHeight; /* 可见区域高度 */ var clientHeight = document.documentElement.clientHeight||document.body.clientHeight; /* 当scrolltop加clientHeight 等于scrollHeight */ if(scrollHeight === (scrolltop+clientHeight)){ loadmore(); } }

// 特定区域元素
handleScroll() {
// -160 去掉非可视List内容区高度 var scrollTop = this.answerRef.scrollTop; // 滚动条溢出高度 var windowHeight = (document.documentElement.clientHeight - 160) || (document.body.clientHeight - 160); // 可视窗口高度 var scrollHeight = this.answerRef.scrollHeight; // 滚动内容高度 // console.log(scrollTop, windowHeight, scrollHeight) if (scrollTop + windowHeight == scrollHeight) {this.pageInfo.pageNum++; return false; } },

this.$nextTick(() => {
this.answerRef = this.$refs.answer;
window.addEventListener("scroll", this.handleScroll, true);
})
 

 

页面滚动到底部加载更多分页

原文:https://www.cnblogs.com/jiaqi1719/p/13728153.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!