滚动内容的高度-滚动容器的高度-设置或获取位于对象最顶端和窗口中可见内容的最顶端之间的距离(获取元素到滚动列表顶部的距离)

 this.getToBottom= (this.getScrollHeight()-this.getClientHeight()-this.scrollTop)
getScrollHeight(){
      return this.$refs.navConListRef.scrollHeight;
    },
    getClientHeight(){
      var clientHeight = 0
      if (document.body.clientHeight && document.documentElement.clientHeight) {
        clientHeight = Math.min(document.body.clientHeight, document.documentElement.clientHeight)
      } else {
        clientHeight = Math.max(document.body.clientHeight, document.documentElement.clientHeight)
      }
      return clientHeight
    },
   
    getScrollTop () {
      this.scrollTop = this.$refs.navConListRef.scrollTop
      console.log(this.scrollTop)
      // this.$refs.navConListTrRef.style.transform = 'translateY(-'+(this.scrollTop)+ 'px)'
    },

 

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐