Technology Sharing

【React】Ant Design -- Implementation of Table paging function

2024-07-12

한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina

Implementation steps

  1. Specify the pagination attribute for the Table component to display the paging effect
  2. Get the selected data in the filter form in the paging switching event
  3. Use the current page data to modify the params parameter dependency to cause the interface to be re-called to obtain the latest data
const pageChange = (page) => {
    // 拿到当前页参数 修改params 引起接口更新
    setParams({
      ...params,
      page
    })
}

return (
   <Table rowKey="id" columns={columns} dataSource={article.list} pagination={{
      current: params.page,
      pageSize: params.per_page,
      onChange: pageChange,
      total: article.count
    }} />
)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16

Related properties

insert image description here
insert image description here
insert image description here