mounted () {
// 监听滚动
this.dom = document.querySelector('.mb-list-scorll')
this.dom.addEventListener('scroll', this.scrollFn)
},
beforeDestroy () {
// 移除监听
this.dom.removeEventListener('scroll', this.scrollFn)
},
// 滚动分页
scrollFn () {
const scrollDistance =
this.dom.scrollHeight - this.dom.scrollTop - this.dom.clientHeight
const scrollTop = this.dom.scrollHeight
if (scrollDistance <= 0) {
console.log('到底啦!!!')
// 加载内容
setTimeout(() => {
if (this.dataList.length < this.count) {
this.page++
this.getList()
this.dom.scrollTop = scrollTop
} else {
}
}, 300)
}
},
本文标题:vue 滚动到底部分页
本文链接:https://www.haomeiwen.com/subject/skbiedtx.html
网友评论