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 } } }); },