window.addEventListener('scroll', function() {
// 获取页面滚动距离顶部的高度, window.pageYOffse 兼容苹果
let top = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop,
// 获取页面的可视高度
scrollHeight = document.documentElement.scrollHeight || document.body.scrollHeight, //总高度
clientHeight = document.documentElement.clientHeight || document.body.clientHeight;
if ((top + clientHeight + 1) >= scrollHeight) {
console.log('到底了')
}
})
网友评论