vue 监听某个div垂直滚动条下拉到底部

this . $nextTick (() => {
const el = document . querySelector ( '.act-not' );
const offsetHeight = el . offsetHeight ;
el . onscroll = () => {
const scrollTop = el . scrollTop ;
const scrollHeight = el . scrollHeight ;
if (( offsetHeight + scrollTop ) - scrollHeight >= - 1 ) {
// 需要执行的代码
}
};
});

坑:在做滚动加载分页时候,有时候第三方的弹窗如elementui 会出问题 ,这时候需要watch变量弹窗关闭时修改el.scrollTop=0即可

猜你喜欢

转载自blog.csdn.net/qq_22978533/article/details/79286543
今日推荐