<ul class="list" ref="scrollBox">
<li v-for="(item, index) in data" :key="index">
...
</li>
</ul>
<script>
mounted() {
this.$nextTick(() => {
this.$refs.homeUl.addEventListener(
'scroll',
this.handleScroll,
true
);
});
},
methods: {
handleScroll() {
const scrollTop = this.$refs.scrollBox.scrollTop;
const windowHeitht = this.$refs.scrollBox.clientHeight;
const scrollHeight = this.$refs.scrollBox.scrollHeight;
if (Math.round(scrollTop) + windowHeitht === scrollHeight) {
this.loadData();
}
},
}
</script>
<style>
.list{
height: calc(100% - xxx);
overflow: scroll;
}
</style>