javascript - 如何在表格底部放置表格分页?
问题描述
我怎么能为表格放置表格分页?
下面是 material-ui 表的代码。文档非常混乱:
<Table ria-label="a dense table">
<TableHead>
<TableRow>
<TableCell>First Name</TableCell>
<TableCell>Last Name</TableCell>
<TableCell>Phone Number</TableCell>
<TableCell>Delete</TableCell>
</TableRow>
</TableHead>
<TableBody>
{names &&
names.map((user) => (
<TableRow>
<TableCell component="th" scope="row">
{user.firstName}
</TableCell>
<TableCell>{user.lastName}</TableCell>
<TableCell numeric>{user.phoneNumber}</TableCell>
<TableCell>
<IconButton
aria-label="delete"
color="secondary"
onClick={() => console.log(`${user.id}`)}
>
<DeleteIcon />
</IconButton>
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
解决方案
添加后TableFooter
_TablePagination
TableBody
<TableFooter>
<TableRow>
<TablePagination
rowsPerPageOptions={[5, 10, 25, { label: "All", value: -1 }]}
count={100}
rowsPerPage={10}
page={0}
...
/>
</TableRow>
</TableFooter>;
推荐阅读
- sql - 如何在 SELECT 区域中编写方程式
- machine-learning - ERROR:root:Error processing image while training Mask-RCNN
- php - 使用 cURL PHP 从页面获取所有 cookie
- react-native - 创建了一个自定义按钮组件,但我无法让它显示为禁用
- php - 将具有内部类的类的实例存储到 mySQL 数据库中
- google-cloud-pubsub - Google Classroom Pub/Sub 注册返回 403 身份验证错误
- node.js - 如何在生产服务器上部署 React Frontend + Node Backend?
- visual-studio-code - 从 Visual Studio Code 生成 apk
- c# - 需要在我的 c# web api 中修复错误的加密方法
- javascript - 如何修复轮播的 Swiper Js 初始加载?