<div ref="rightDiv">11233</div>
mounted(){
this.$refs.rightDiv.addEventListener('scroll',this.scroll)
// debounce 是一个防抖工具类函数 需要自己定义
}
scroll() {
const scrollTop = this.$refs.rightDiv.scrollTop
// 获取可视区的高度
const windowHeight = this.$refs.rightDiv.clientHeight
// 获取滚动条的总高度
const scrollHeight = this.$refs.rightDiv.scrollHeight
console.log(
'scrollTop',
scrollTop,
'windowHeight',
windowHeight,
'scrollHeight',
scrollHeight
)
if (scrollTop + windowHeight >= scrollHeight ) {
// 把距离顶部的距离加上可视区域的高度 等于或者大于滚动条的总高度就是到达底部
// 调用函数
}
},
07-03
1887

03-20
1519

07-10
994

02-24
413
