首先mounted挂载监听

mounted(){
    window.addEventListener("scroll", this.handleScroll, true);
    }

methods创建监听方法

methods:{
        handleScroll(){
            let scrollTop = document.documentElement.scrollTop;//滚动高度
            let clientHeight = document.documentElement.clientHeight;//可视高度
            let scrollHeight = document.documentElement.scrollHeight;//内容高度
            console.log("滚动高度",scrollTop);
            console.log("可视高度",clientHeight);
            console.log("内容高度",scrollHeight);
        }
    },

滚动高度+可视高度==内容高度

ok!

Logo

前往低代码交流专区

更多推荐