import { debounce } from "lodash"; export default { data() { return { listData: [], finished: false, // 是否已经到最低 loadStatus: "loadmore", isThrottled : false, } }, methods: { async handleLoadData(){ this.loadStatus = "loading" const rows = await this.getList(); this.listData = this.listData.concat(rows); this.loadStatus = "loadmore" if(rows.length < this.queryParams.pageSize){ this.finished = true; } }, resetData: debounce(function() { this.queryParams.pageNum = 1; this.listData = []; this.finished = false; this.loadStatus = "loadmore"; this.handleLoadData(); // 实际加载数据 this.getOtherData && this.getOtherData(); }, 100), // resetData(){ // this.queryParams.pageNum = 1; // this.listData = []; // this.finished = false; // this.loadStatus = "loadmore"; // this.handleLoadData(); // }, handleReachBottom(){ if (this.finished) return; this.queryParams.pageNum += 1; this.handleLoadData(); }, }, onReachBottom() { this.handleReachBottom(); } }