// 注册scroll事件并监听 )
window.
addEventListener(
'scroll',
function(){
console.
log(
page)
console.
log(
"可视区高度"+
document.
documentElement.
clientHeight+
'-----------'+
window.
innerHeight);
// 可视区域高度
console.
log(
"滚动高度"+
document.
body.
scrollTop+
`------`+
document.
documentElement.
scrollTop);
// 滚动高度
console.
log(
"文档高度"+
document.
body.
offsetHeight);
// 文档高度
// 判断是否滚动到底部
if(
document.
body.
scrollTop +
window.
innerHeight >=
document.
body.
offsetHeight ||
document.
documentElement.
scrollTop +
window.
innerHeight >=
document.
body.
offsetHeight) {
//滚动高度+可视区高度>=文档高度
console.
log(
sw);
// 如果开关打开则加载数据
if(
sw==
true){
// 将开关关闭
sw =
false;
ajax({
method:
'get',
})
}
}
});
},