element table组件懒加载

directives : {
    loadmore : {
      bind(el, binding) {
        const selectWrap = el.querySelector('.el-table__body-wrapper')
        selectWrap.addEventListener('scroll', function() {
          let sign = 0
          const scrollDistance = this.scrollHeight - this.scrollTop - this.clientHeight
          if (scrollDistance <= sign) {
            binding.value()
          }
        })
      }
    }
  },

// 自定义指令后,在el-table标签下使用v-loadmore

 <el-table v-loadmore="loadMore"  >
</el-table>

  

// 方法
 loadMore () {
      this.page++
},

  

  

原文地址:https://www.cnblogs.com/hpx2020/p/11889481.html