vue判斷滾動條到底部


        mounted() {
                this.$nextTick(() => {
            // 進入nexTick
var bady = document.getElementById("dody"); // 獲取滾動條的dom // console.log("距頂部"+scrollTop+"可視區高度"+windowHeight+"滾動條總高度"+scrollHeight); bady.onscroll = () => {
               // 獲取距離頂部的距離
var scrollTop = bady.scrollTop; // 獲取可視區的高度 var windowHeight = bady.clientHeight; // 獲取滾動條的總高度 var scrollHeight = bady.scrollHeight; console.log("距頂部"+scrollTop+"可視區高度"+windowHeight+"滾動條總高度"+scrollHeight); if(scrollTop+windowHeight>=scrollHeight){ // 把距離頂部的距離加上可視區域的高度 等於或者大於滾動條的總高度就是到達底部 this.shows = false } } }); },


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM