最佳答案
对于分页你需要:
- 知道记录的数量。
- 页面上显示的记录数。
- 页码。
从客户端发送到服务器:页面记录数
和页码
)
从服务器发送到客户端:records
between from
, to
const count = 20; // for example we have 20 records
const size = 7; // there are 7 records on each page
// number of pages
const countPages = Math.ceil (20/7);
//show records on page 2:
const page = 2; // display 2nd page
const from = (page - 1) * size;
const to = Math.min (from + size- 1, count);
console.log(`we have ${count} records, ${size} per page` )
console.log('number of pages', countPages);
console.log(`on page ${page} records from ${from} to ${to}`);
关于reactjs - 如何使用 Material ui 实现服务器端分页并使用react?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65317005/