data(){
    return{
        scrollTop:'',
    }
}



created() {
    this.listenerFunction();
},
beforeDestroy () {
    document.removeEventListener("scroll", this.listenerFunction);
},
methods: {
    listenerFunction(e) {
        document.addEventListener('scroll', this.handleScroll, true);
    },
    handleScroll (event) {
        console.log("滚动条高度为:",event.target.scrollTop)
        this.scrollTop=event.target.scrollTop
    },
}

Logo

前往低代码交流专区

更多推荐