注册滚动事件
window.addEventListener('scroll', this.onScroll, true)
事件触发
onScroll () {
let scrollTop = document.documentElement.scrollTop || document.body.scrollTop
let clientHeight = document.documentElement.clientHeight
let scrollHeight = document.documentElement.scrollHeight
if (scrollTop + clientHeight >= scrollHeight) {
this.findBlogsContentInfo()
}
},
利用JavaScript实现网页滚动事件监听与内容加载
本文介绍了如何使用JavaScript为网页添加滚动事件监听器,当用户滚动到页面底部时,会触发`onScroll`函数,通过检测scrollTop、clientHeight和scrollHeight计算条件,进而调用`findBlogsContentInfo`方法加载更多内容。
1110





