第一步:
mounted() {
window.addEventListener('scroll', this.handleScroll)
},
第二步:
methods:{
handleScroll() {
const scrollTop = document.documentElement.scrollTop || document.body.scrollTop
const scrollHeight = document.documentElement.scrollHeight || document.body.scrollHeight
const clientHeight = document.documentElement.clientHeight || window.innerHeight
if (scrollTop + clientHeight >= scrollHeight) {
加载更多。。。
}
},
}