【发布时间】:2020-07-18 15:38:38
【问题描述】:
所以我有一些表格,我试图按日期分类,标题如(今天、昨天、上周……),我试图根据视口中的当前表格使它们具有粘性。我尝试使用 react-sticky 库,特别是 the stacked example,因为它似乎是我正在寻找的效果,但我无法重新创建它。
拜托,我是否遗漏了一些关于图书馆使用的事情。
也非常欢迎没有库的解决方案
我一直在尝试什么
export default function CustomizedTables() {
const classes = useStyles();
return (<StickyContainer>
<Sticky topOffset={20}>
{(props) => (<div className={reduceCSS.tableHistoryTitle_day}>Today</div>)}
</Sticky>
<TableContainer component={Paper} elevation={0}>
<Table className={classes.table} aria-label="customized table">
<TableBody>
{rows.map((row) => (
<StyledTableRow key={row.name} elevation={0}>
<StyledTableCell align="left" className={classes.iconCell}><AssignmentReturnedSharpIcon className={classes.inputIcon} /></StyledTableCell>
<StyledTableCell align="left">{row.calories}</StyledTableCell>
<StyledTableCell component="th" scope="row">
{row.name}
</StyledTableCell>
<StyledTableCell align="right">{row.fat}</StyledTableCell>
<StyledTableCell align="right">{row.carbs}</StyledTableCell>
<StyledTableCell align="right">{row.protein}</StyledTableCell>
</StyledTableRow>
))}
</TableBody>
</Table>
</TableContainer>
</StickyContainer>
);
}
【问题讨论】:
标签: javascript reactjs next.js react-sticky