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++
},

  

  

posted @ 2019-11-19 14:54  惠鹏曦  阅读(5810)  评论(0编辑  收藏  举报