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) //页面离开后销毁监听事件
},
更多推荐
已为社区贡献26条内容
所有评论(0)