- mounted() {
- // 监听el-table滚动
- window.addEventListener("scroll", this.loadMore, true);
- },
后端接口没有分页,一次性返回全部数据,前端监听滚动条加载数据。
this.tableList当前表格展示的数据
this.allTableData接口获取的全部数据
- loadMore() {
- let curlens = this.allTableData.length;
- let showlens = this.tableList.length;
- if (showlens >= curlens) {
- return;
- } else {
- this.tableList.push(
- ...this.allTableData.slice(showlens, showlens + 10)
- );
- }
- },
- //接口获取表格数据
-
- abStsLog(this.filters).then((res) => {
- this.tableList = res.data.slice(0,20);
- this.allTableData = res.data;
- this.listLoading = false;
- });