使用React的材料UI,我尝试为流程中的每4个步骤创建“页面”。
下面的尝试导致所有10个步骤仍然显示在一个视图中,而分页计算每4个步骤的正确页数。
return (
<Grid>
<Stepper>
{statusArr.map((label) => {
return (
<Step key={label}>
<StepLabel>{label}</StepLabel>
</Step>
);
})}
</Stepper>
<TablePagination
component="div"
count={statusArr.length}
rowsPerPage={[4]}
page={page}
backIconButtonProps={{
'aria-label': 'previous page',
}}
nextIconButtonProps={{
'aria-label': 'next page',
}}
onChangePage={handleChangePage}
/>
</Grid>
);理想情况下,我应该让Stepper "dots“表示的每一页步骤都显示为here,而不是表格的分页外观/功能。
如果上下文需要额外的代码,请让我知道,并感谢您的想法/建议。
发布于 2019-10-15 02:44:10
你只需要做一些数学运算就可以得到正确的页数
...
const stepsPerPage = 4;
const pageCount = Math.ceil(statusArray.length / stepsPerPage);
return (
<Grid>
<Stepper>
{Array(pageCount).fill().map(page => (
<Step>
...https://stackoverflow.com/questions/58380316
复制相似问题