function addScrollEvent() { let canScroll = true; function isScrollToPageBottom() { let docHeight = document.documentElement.offsetHeight; let viewHeight = window.innerHeight; let scrollHeight = window.pageYOffset; return docHeight - viewHeight - scrollHeight < 20; } document.onscroll = function () { // console.log(isScrollToPageBottom());// true 为底部 if (canScroll && isScrollToPageBottom()) { // 滑到底部 canScroll = false; if (arr.length > 5) { document.getElementsByClassName('content')[0].innerHTML = '1000'; // 处理一些事件 } else { canScroll = true; } } }.bind(this); }