js上拉刷新,下拉加载滚动事件监控(滚动区域为body)

    handleScroll () {
      let scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop
      this.scroll = scrollTop
       // 变量windowHeight是可视区的高度
      let windowHeight = document.documentElement.clientHeight || document.body.clientHeight
      // 变量scrollHeight是滚动条的总高度
      let scrollHeight = document.documentElement.scrollHeight || document.body.scrollHeight
      if (scrollTop + windowHeight === scrollHeight && (this.productList.length !== this.total)) {
        if (!this.loadData) {
          this.loadData = true
          this.loadMoreTips = '加载更多中...'
          this.nextPage()
        }
      }
    }

你可能感兴趣的:(js上拉刷新,下拉加载滚动事件监控(滚动区域为body))