<div ref="scrollbar" style="height:500px" @scroll="handleScroll"></div>
data() {
return {
scrollTop: 0, //列表分页加载定位
}
},
mounted() {
this.handleScroll()
}
handleScroll() {
if (!this.$refs.scrollbar || this.$refs.scrollbar.scrollTop === 0) return
let scrollTop = this.$refs.scrollbar.scrollTop
let scrollHeight = this.$refs.scrollbar.scrollHeight
let clientHeight = this.$refs.scrollbar.clientHeight
if ((scrollHeight - clientHeight) <= scrollTop) {
//滚动条滚到底部
if (this.pagination.currentPage < this.pagination.totalPages) {
this.scrollTop = scrollTop
this.pagination.currentPage++
this.getRoomList().then(() => {
this.$refs.scrollbar.scrollTop = this.scrollTop
})
}
}
},