VUE监听页面滚动到底部
methods:{Scrollbottom () {let scrollTop = document.documentElement.scrollTop || document.body.scrollTop;let clientHeight = document.documentElement.clientHeight;let scrollHeight = document.documentEle
·
methods:{
Scrollbottom () {
let scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
let clientHeight = document.documentElement.clientHeight;
let scrollHeight = document.documentElement.scrollHeight;
if (scrollTop + clientHeight >= scrollHeight) {
console.log("滚动到底部了")
}
},
},
created(){
window.addEventListener('scroll', this.Scrollbottom);
},
destroyed() {
window.removeEventListener('scroll', this.Scrollbottom)//页面离开后销毁监听事件
},
遇到问题可以看我主页加我Q,很少看博客,对你有帮助别忘记点赞收藏
更多推荐
已为社区贡献11条内容
所有评论(0)