简单粗暴,直接上代码
- el-table-loadmore/index.js文件
const vueClearIndex = {}
vueClearIndex.install = Vue => {
Vue.directive('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()
}
})
}
})
}
export default vueClearIndex
import loadmore from '@/directive/el-table-loadmore'
loadmore.install(Vue)
<el-table ref="multipleTable" :data="detailList" style="width: 100%;" :max-height="maxHeight" v-loadmore="loadMore">
...
</el-table>
loadMore() {
if (this.searchData.currentPage < this.pages) {
this.searchData.currentPage++;
this.getData()
}
},
|