methods:{
// 触底加载更多
    handleScroll() {
      let scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
      let clientHeight = document.documentElement.clientHeight;
      let scrollHeight = document.documentElement.scrollHeight;
      if (scrollTop + clientHeight >= scrollHeight) { // 如果滚动到接近底部,自动加载下一页
            //事件处理
            this.getMore()
      }    
    },
}
mounted() {
    // body背景颜色
    // document
    //   .querySelector("body")
    //   .setAttribute("style", "background-color:#ebebeb");
      // 触底加载更多
       window.addEventListener("scroll", this.handleScroll);
    this.getData()
  },
  beforeDestroy() {
    //document.querySelector("body").removeAttribute("style");
    window.removeEventListener("scroll", this.handleScroll,false);
  },



pc的mounted和beforeDestroy的写法 不然跳转其他页面也会加载
mounted() {
       window.addEventListener('scroll', this.handleScroll,true)
    
  },
  beforeDestroy() {
    //document.querySelector("body").removeAttribute("style");
    window.removeEventListener('scroll', this.handleScroll, true)
  },

更多推荐

节流下拉加载更多