vue 自定义 滚动条指令

Vue.directive('scroll', {
  bind: (el, binding, vnode) => {
    // 是否执行回调事件
    let eventAction = true
    // 距离底部剩余距离开始触发回调
    let distance = 100 // (unit: px)
    // 监听滚动事件
    el.onscroll = (e) => {
      binding.value()
    } 
  }
})
原文地址:https://www.cnblogs.com/tutao1995/p/12096442.html