front endFirst, you need to be familiar with the attribute pagination in the table in the front-end react <Pagination onChange={onChange} total={50} /> <Table bordered columns={columns} rowKey={record => record.id} dataSource={dataSource} pagination={pagination}/> Among them, pagination is a function that we implement ourselves. Since only static samples are given in react, we can check the react documentation. The example given is as follows It reminds us that the function parameters are current and pageSize According to the above ideas, design and write the page turner functionconst pagination = { showQuickJumper:true, showSizeChanger:[], total: this.example.total, defaultCurrent: this.example.page, current: this.example.page, pageSize: this.example.pageSize, hasNextPage: this.example.hasNextPage, onShowSizeChange: (current, size) => { // Maximum amount of data per page self.example.pageSize = size; //Current page self.example.page = current; // Encapsulate two parameters in a temple let temple = { page : self.example.page, pageSize : self.example.pageSize }; // Finally, re-request the function and pass the current page and the maximum amount of data for each page into the re-request parameters self.onFetch(temple); }, onChange(current, pageSize) { self.example.pageSize = pageSize; self.example.page = current; let temple = { page : self.data.search.page, pageSize : self.data.search.pageSize, }; self.onFetch(temple); } }; At this point we have implemented the front-end function of the pager, so we can pass the pagination into the pagination in the table Backend (taking Java as an example) First we need to write a SQL select id from stu limit ${(page - 1)*(pageSize)}, ${pageSize + 1} Interpreting SQL, some people may ask why pageSize is increased by 1 countSize is 201 pageSize is 20 you divide directly the result is 10 but actually need 11 We can use mybatis-helper or encapsulate PageList ourselves on the backend Regarding the issue of SQL parameter passing When we write SELECT id FROM Stu LIMIT 1,10 The data found is 218 222 220 217 219 221 8 9 10 12 NoticeWhen we write SQL as (page-1), the default page value of the front end must start from 1. Otherwise, if 0 is passed in, a negative number will appear and our back end will generate an error. For more information on how to optimize limit, please refer to my other article "In-depth Study of MySQL Select Optimization" This is the end of this article about the implementation of React page turner (including front-end and back-end). For more relevant React page turner content, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Detailed steps to install mysql in Win
>>: Detailed explanation of Svn one-click installation shell script under linxu
MySQL installation tutorial, for your reference, ...
1. nohup Run the program in a way that ignores th...
1. The startup menu is to move the cursor to the ...
Environmental Statement Host OS: Cetnos7.9 Minimu...
Without further ado, I'll go straight to the ...
1. Unzip MySQL 5.7 2. Create a new configuration ...
Implementation ideas: First of all, the alarm inf...
The loading speed of a web page is an important in...
Table of contents principle Network environment p...
In many cases, arrays are often used when writing...
Using the internal function instr in MySQL can re...
Install nginx Note that you must install nginx-fu...
1. Implement call step: Set the function as a pro...
This article example shares the specific code of ...
<br />This is not only an era of information...