The element Ui paging size-change event triggers the current-change event at the same time, resulting in two calls to the interface

element Ui paging size-change event triggers also initiates current-change event, resulting in two calls to the interface

<el-pagination 
  @size-change="handleSizeChange"
  @current-change="handleCurrentChange" 
  :current-page.sync="pageInfo.PageNum" 
  :page-sizes="[5, 10, 20]"
  :page-size="pageInfo.PageSize" 
   layout="total, sizes, prev, pager, next, jumper" :total="pageInfo.Total">
</el-pagination> 
    //pageSize
   handleSizeChange(val) {
        this.$emit("sizeChange", val);
  },

  //pageNum
  handleCurrentChange() {
    this.$emit("pageNumCheng");
  }
There is a bit of a problem with
handleSizeChange(val) {
                this.options.limit = val;
                this.getData();
},
            handleCurrentChange(val) {
                this.options.offset = this.options.limit * (val - 1);
                this.getData();
            }

, because there are usually two situations when size changes: the number of pages has changed and the number of pages has not changed. So sometimes it triggers, sometimes it doesn't. So my suggestion is to request the interface when the size changes, and set a flag, if the size changes, the curent-change event does not trigger the request interface, wait until the interface requested by the size comes back, and then set the flag to reverse

.
Menu