How to implement and reuse paging components? Why don't you give me an idea?

for example, if a page uses a paging component, there must be a method to write the request inside the paging component, but the data obtained by different pages must not be the same request (the interface address requested by different pages must not be the same). What are we going to do with this?


it is not recommended to encapsulate the request in the paging component. All major UI frameworks have ready-made paging components. The request to the backend is nothing more than the current request page current-page and the number of request entries per page page-size . When the page listens to these two attribute changes of the component, resubmit the request, and the logic is very clear.
if you encapsulate the request in the paging component, you need to pass the request method as a parameter. The component must also be able to accept additional parameters of the request. It is necessary to provide a manual request API. After the request is called back, you have to get the callback from the paging component, right? This can be achieved, but it always feels that the logic is not correct

< hr >

take element-ui as an example to intercept a segment of my implementation

<el-pagination
    @size-change="tableSizeChange"
    @current-change="tablePageChange"
    :current-page="table.page"
    :page-sizes="table.pageSizes"
    :page-size="table.pageSize"
    :total="table.total"
    layout="total, sizes, prev, pager, next, jumper">
</el-pagination>
data() {
  return {
    search:{                                //
      status: 'ALL',
      create_time: [start, end],
      seller_flag: -1,
      buyer_remark: 0,
      seller_remark: 0,
      address_code: '',
      keyword_trade: '',
      keyword_sku: '',
      keyword_address: ''
    },
    table: {
      pageSize: 20,                         //
      pageSizes: [20, 30, 50, 100],         //
      page: 1,                              //
      total: 0,                             // 
      sort: {},                             //
    },
  }
},
methods: {
  tableSizeChange(size) {
    this.table.pageSize = size;
    this.onSearchSubmit()
  },
  tablePageChange(page) {
    this.table.page = page;
    this.onSearchSubmit()
  },
  onSearchSubmit() {
    this.loading = true;
    this.$store.dispatch('tradeSearch', {
      ...this.search,
      page: this.table.page,
      page_size: this.table.pageSize,
      callback: res => {
        this.loading = false;
        if (!res.code) {
          if (res.data.page === 1) {
             this.table.total = res.data.total
          }
          this.list = res.data.list.map(({id}) => id);
        } else {
          this.list = [];
        }
      }
    });
  },
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e52003-4372c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e52003-4372c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?