She*_*lly 7 reactjs material-ui material-table
我正在尝试将 react material-table ( https://github.com/mbrn/material-table ) 与我的项目集成。
我用过类似的东西。
<MaterialTable options={{
rowStyle: x => {
if ( x.id % 2 ) {
return { backgroundColor: "#f2f2f2" }
}
},
'headerStyle' : {
backgroundColor: 'red',
color: theme.palette.common.white
}
}}
columns={columns}
data={data}
title="New Table"
/>
Run Code Online (Sandbox Code Playgroud)
但是我想要一个通用的样式和主题,比如
const CustomTableCell = withStyles(theme => ({
head: {
backgroundColor: theme.palette.common.black,
color: theme.palette.common.white,
},
body: {
fontSize: 14,
},
}))(TableCell);
Run Code Online (Sandbox Code Playgroud)
基本上我想要像 CustomMaterialTable 这样的东西,它只是我的主题/风格。
if ( x.id % 2 ) {
return { backgroundColor: "#f2f2f2" }
}
Run Code Online (Sandbox Code Playgroud)
由于我的表将进行排序,我希望它位于自动生成的行 id 而不是 x.id (其中 x 是我的数据)。
小智 4
您可以覆盖组件。看示例: https: //mbrn.github.io/material-table/#/docz-examples-10-example-component-overriding
你可以尝试x.tableData.id代替吗x.id?
您应该使用带有方向的material-ui主题(ltr或rtl):https://material-ui.com/customization/themes/
| 归档时间: |
|
| 查看次数: |
6765 次 |
| 最近记录: |