1、安装插件
npm install --save el-table-infinite-scroll
2、局部引用
import elTableInfiniteScroll from 'el-table-infinite-scroll';
3、js
directives: {
'el-table-infinite-scroll': elTableInfiniteScroll,
},
setup() {}
//加载更多
const loadResult = () => {
if (state.count < state.resultListTotal.length) {
state.count += 5
} else {
state.count = state.resultListTotal.length
state.isLoad = true
}
state.resultList = state.resultListTotal.slice(0, state.count)
}
//获取发票批及配单结果
const matchInvoiceBatchFun = async () => {
try {
state.resultLoading = true
const data = await $matchInvoiceBatch({
id: route.query.id,
flag: 'CMS',
})
state.resultLoading = false
state.batchForm = data.data
state.invoiceBatchId = data.data.id
state.resultListTotal = data.data.invoiceBatchMatchResult
state.resultList = state.resultListTotal.slice(0, 5)
state.expandRowKeys = []
state.resultListTotal?.forEach((i) => {
state.expandRowKeys.push(i.invoiceId)
})
state.invoiceHeaderData = JSON.parse(
sessionStorage.getItem('invoiceHeaderData')
)
} catch (error) {
state.resultLoading = false
}
}
4、html
<el-table
ref="tableSortRef"
v-loading="resultLoading"
:border="border"
:cell-class-name="orderRowClassName3"
class-name="resultTableAll"
:data="resultList"
@selection-change="resultSelectChange"
class="infinite-list"
v-el-table-infinite-scroll="loadResult"
:infinite-scroll-disabled="isLoad"
:infinite-scroll-immediate="isLoad"
>
<el-table-column align="center" type="selection" width="30" />