【发布时间】:2020-10-12 04:34:46
【问题描述】:
有没有办法在材质ui中使用自定义图标进行分页?
Material UI Pagination Documentation , CodeSandbox Demo
我想更改默认的左右人字形(用于导航)
有没有办法使用material ui的现有组件来实现这一点?
【问题讨论】:
标签: css reactjs material-ui
有没有办法在材质ui中使用自定义图标进行分页?
Material UI Pagination Documentation , CodeSandbox Demo
我想更改默认的左右人字形(用于导航)
有没有办法使用material ui的现有组件来实现这一点?
【问题讨论】:
标签: css reactjs material-ui
你不能直接改变图标,但你可以使用usePagination自定义完整的分页
<ul className={classes.ul}>
{items.map(({ page, type, selected, ...item }, index) => {
let children = null;
if (type === 'start-ellipsis' || type === 'end-ellipsis') {
children = '…';
} else if (type === 'page') {
children = (
<IconButton style={{
fontWeight: selected ? 'bold' : undefined,
backgroundColor: selected ? 'rgba(0, 0, 0, 0.04)' : 'white',
width: 50,
height:50
}} {...item}>
{page}
</IconButton >
);
} else {
children = (
<IconButton {...item}>
{type === 'previous' ? <FastRewindIcon/> : <FastForwardIcon/>}
</IconButton >
);
}
return <li key={index} style={{ margin: 'auto 0'}}>{children}</li>;
})}
</ul>
【讨论】:
js const { items } = usePagination({ count: 10, onChange: (event,page) => console.log(page) }); 这样使用usePagiantion中的所有属性