【发布时间】:2022-02-03 03:33:39
【问题描述】:
我想覆盖 Material UI 中所选分页项的背景颜色,但它无法正常工作。
有时它会变成正确的颜色,但在我刷新页面后它又变成了错误的颜色。
这是我的代码
export default function CustomPagination (props) {
const _screenClass = useScreenClass();
const _isBigScreen = (['lg', 'xl', 'xxl'].includes(_screenClass));
const {
count,
defaultPage,
currentPage,
} = props;
return <Pagination
defaultPage={1}
count={count}
sx = {{
'& .Mui-selected': {
backgroundColor: "#f16037",
color:'white',
borderColor: 'transparent',
fontSize: 16,
height: "32px",
width: "32px",
borderRadius: "8px",
},
}}
boundaryCount={_isBigScreen ? 2 : 1}
siblingCount={0}
renderItem={(item) => {
return <PaginationItem
components={{ previous: KeyboardDoubleArrowLeftIcon, next: KeyboardDoubleArrowRightIcon }}
selected = {item.page == currentPage}
{...item}
/>;
}}
/>
}
【问题讨论】:
标签: reactjs pagination material-ui styles