我创建了一个包含数据的Material UI Grid,使用MUI网站构建它,我希望它看起来像这样:
What I would like my chart to look like
相反,它看起来像这样,好像它无法读取“密集表”属性:
What it actually looks like的
下面是我的代码:
<Card className="flightPlanCard" style={{ maxHeight: 300, overflow: 'auto', backgroundColor: "rgba(255,255,255,.5)" }}>
<TableContainer component={Paper}>
<Table size="small" aria-label="a dense table" >
<TableHead>
<TableRow>
<StyledTableCell>ID</StyledTableCell>
<StyledTableCell align="center">Fréquence</StyledTableCell>
<StyledTableCell align="center">Track</StyledTableCell>
<StyledTableCell align="center">Distance (NM)</StyledTableCell>
<StyledTableCell align="center">Coordonées</StyledTableCell>
<StyledTableCell align="center">Nom/Remarque</StyledTableCell>
</TableRow>
</TableHead>
<TableBody style={{ fontSize: 10 }}>
{rows.map((row) => (
<TableRow key={row.name} style={{ height: 10 }} >
<StyledTableCell component="th" scope="row">
{row.id}
</StyledTableCell>
<StyledTableCell align="center">{row.frequency}</StyledTableCell>
<StyledTableCell align="center">{row.track}</StyledTableCell>
<StyledTableCell align="center">{row.distance}</StyledTableCell>
<StyledTableCell align="center">{row.coordinates}</StyledTableCell>
<StyledTableCell align="center">{row.name}</StyledTableCell>
</TableRow>
))}
</TableBody>
</Table>
</TableContainer>
</Card>
字符串
TableContainer位于Card中,运行应用程序时也会出现错误:
Material-UI: The key `row` provided to the classes prop is not implemented in ForwardRef(TableCell).
You can only override one of the following: root,head,body,footer,sizeSmall,paddingCheckbox,paddingNone,alignLeft,alignCenter,alignRight,alignJustify,stickyHeader.
型
我该如何解决此问题?
Thanks in advance
1条答案
按热度按时间g52tjvyc1#
我找到了一个很好的解决方案来解决这个问题:你必须在文件夹/pages中添加一个名为_document.jsx的文件,其中包含以下代码:
字符串
就是这样!没有什么可导入的,它只是工作:)