vue滚动条滚动到底部触发事件
//获取节点const scrollDiv = this.$refs.mypklogList//vue的写法 mypklogList是表现中 ref=“mypklogList”const scrollDiv=document.getElementById(‘id’) //js的写法 上面的和这个选择一个const offsetHeight = scro...
·
//获取节点
const scrollDiv = this.$refs.mypklogList //vue的写法 mypklogList是表现中 ref=“mypklogList”
const scrollDiv=document.getElementById(‘id’) //js的写法 上面的和这个选择一个
const offsetHeight = scrollDiv.offsetHeight;
//绑定事件
scrollDiv.addEventListener('scroll', function() {
const scrollTop = scrollDiv.scrollTop;
const scrollHeight = scrollDiv.scrollHeight;
if (offsetHeight + scrollTop >= scrollHeight ) {
//触发事件
}
})```
更多推荐
已为社区贡献11条内容
所有评论(0)