材质ui表水平滚动

Jer*_*me 1 html-table scrollbar material-ui

我在我的Material-UI的水平滚动条上苦苦挣扎。尽管我阅读了文档并在此处浏览了一些主题,但找不到解决该问题的方法。水平滚动条从不显示。

这是我的代码的子集:

App.js

     <div style={{ height: '100vh', overflow: 'auto', width: '600px' }}>
        <TableHeader headerlabels={headers} datarows={resu} />
     </div >
Run Code Online (Sandbox Code Playgroud)

TableHeader.js

const HeaderTableCell = styled(TableCell)`
&&{
    background-color:#092e68;
    color:white;
    top:0;
    position:sticky;
}
`;

const CustomTableCell = styled(TableCell)`
&&{
    background-color:white;
    color:#092e68;
}
`;


// key, label
const TableHeader = props => {
    const { headerlabels, datarows } = props
    return (
        <Table>
            <TableHead >
                <TableRow key={uuid.v4()} >
                    {headerlabels.map((label) =>
                        (<HeaderTableCell {...props} key={label}>{label}</HeaderTableCell>))}
                </TableRow>
            </TableHead>
            <TableBody >
                {datarows.map((value, id) =>
                    (
                        <TableRow key={id} >
                            {headerlabels.map((label) =>
                                (<CustomTableCell {...props} key={label}>{value[label]}</CustomTableCell>))}
                        </TableRow>
                    )
                )}
            </TableBody >
        </Table>
    )
};
Run Code Online (Sandbox Code Playgroud)

Rya*_*ell 5

如果查看Simple Table演示程序的代码,您会看到它通过将Table包裹在Paper中来处理此问题overflowX: 'auto'

编辑rm0yx1knxq

  • 在提出问题之前已经对此进行了测试,但没有解决问题 (2认同)
  • 在我的 CodeSandbox 上,我得到了一个水平滚动条。您可以发布一个带有显示问题的代码版本的 CodeSandbox 吗? (2认同)