vue 滚动吸顶 + 限流

window.addEventListener('scroll',throttle(handleScroll,100));

let throttle_func = null

throttle(func,delay){

  var context = this

  return function(){

    var args = arguments

    if(!throttle_func){

      throttle_func = setTimeout(function(){

        func.apply(context,args)

        throttle_func = null

      })

    }

  }

}

handleScroll(){

  let offestTop =  this.$el.querySelector('#id').getBoundingClientRect().top //  元素距离页面顶部的距离

}

原文地址:https://www.cnblogs.com/ch-zaizai/p/12218299.html