Vue获取滚动条位置实现滚动条滚动到指定位置

methods: { handleScroll(e) { let scrollTop = document.documentElement.scrollTop //变量windowHeight是可视区的高度 let windowHeight = document.documentElement.clientHeight //变量scrollHeight是滚动条的总高度 let scrollHeight = document.documentElement.scrollHeight //滚动条到底部的条件 let sum = scrollHeight - windowHeight; console.log(sum) console.log(scrollTop) if (scrollTop == sum) { console.log('我到底了') } } } mounted() { this.$nextTick(function() { window.addEventListener("scroll", this.handleScroll, true); //监听滚动事件 }) }
本页地址:https://www.ebo168.com//webkf/50238.html
欢迎转载:Vue获取滚动条位置实现滚动条滚动到指定位置
- 上一篇:没有了!
- 下一篇:DEDE织梦转PBOOTCMS