直接在需要监听的页面最外层div加监听事件
<template>
<div class="contain" @scroll="onScroll">
</div>
</template>
methods:{
onScroll(e){
let scrollTop = e.target.scrollTop;
let scrollHeight = e.target.scrollHeight;
let offsetHeight = Math.ceil(e.target.getBoundingClientRect().height);
let currentHeight = scrollTop + offsetHeight;
if (currentHeight >= scrollHeight) {
console.log('触底了')
}
}
}