js获取高度吸顶

        mounted() {
            this.$nextTick(() => {
                window.addEventListener('scroll', this.scrollWindow)
                let title = document.querySelector("#title")
                title.style.background = "#fff";
                title.style.color = "#333";
                let infoContent = this.$refs.infoContent;
                this.infoContentHeight = infoContent.getBoundingClientRect().top
                console.log(this.infoContentHeight);
            })
        },
            scrollWindow() {
                var scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop
                console.log(scrollTop)
            },
            destroyed() {
                window.removeEventListener('scroll', this.scrollWindow)
            },

猜你喜欢

转载自blog.csdn.net/qq719756146/article/details/86598680