vue检测滚动条到了底部
vue如何监听滚动条到底部了!有手就行!
·
首先mounted挂载监听
mounted(){
window.addEventListener("scroll", this.handleScroll, true);
}
methods创建监听方法
methods:{
handleScroll(){
let scrollTop = document.documentElement.scrollTop;//滚动高度
let clientHeight = document.documentElement.clientHeight;//可视高度
let scrollHeight = document.documentElement.scrollHeight;//内容高度
console.log("滚动高度",scrollTop);
console.log("可视高度",clientHeight);
console.log("内容高度",scrollHeight);
}
},
滚动高度+可视高度==内容高度
ok!
更多推荐
已为社区贡献2条内容
所有评论(0)