监听滚动条滚动到页面的最底部
const handleScroll = () => {
const { scrollHeight, scrollTop, clientHeight } = document.documentElement;
// scrollHeight: 页面的总高度
// scrollTop:页面滚动上去的不可见的高度
// clientHeight:浏览器窗口的高度
if (scrollHeight - scrollTop === clientHeight) {
console.log('我到底部了');
}
}
window.addEventListener('scroll', handleScroll);