700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > JS方法篇:vue.js判断滚动条触底

JS方法篇:vue.js判断滚动条触底

时间:2023-10-06 21:32:54

相关推荐

JS方法篇:vue.js判断滚动条触底

mounted(){window.addEventListener('scroll', this.handleScroll) // 监听页面滚动},methods:{// 获取页面滚动距离handleScroll (event) {//变量scrollTop是滚动条滚动时,距离顶部的距离var scrollTop = document.documentElement.scrollTop||document.body.scrollTop;//变量windowHeight是可视区的高度var windowHeight = document.documentElement.clientHeight || document.body.clientHeight;//变量scrollHeight是滚动条的总高度var scrollHeight = document.documentElement.scrollHeight||document.body.scrollHeight;//滚动条到底部的条件if(scrollTop + windowHeight === scrollHeight){//写后台加载数据的函数console.log("距顶部"+scrollTop+"可视区高度"+windowHeight+"滚动条总高度"+scrollHeight);}}}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。