监听页面滚动高度

data() {
    return {
      top: 0, // 页面滚动高度
    };
  },
//挂载时添加监听事件
mounted() {
    window.addEventListener("scroll", this.scrollHandle); //绑定页面滚动事件
    //mouseover click 等其他事件也可
  },
methods:{
  // 获取页面滚动高度
    scrollHandle(e) {
      this.top = e.srcElement.scrollingElement.scrollTop; // 获取页面滚动高度
    },
 }
 watch: {
    top(v) {
      if (v > 10) {
        this.isOver = true;
      }
      if (v == 0) {
        this.isOver = false;
      }
    },
  },

版权声明:本文为qq_45022585原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。