reactjs - Reactjs 中的 MuiTableSortLabel 样式问题
问题描述
我正在使用 Mui Tables 实现一个数据表。你可以在这里看到预期的结果。问题是我无法将 Sorting SVG Icon 的颜色覆盖为白色并将其作为输出。检查后我知道它是从
.MuiTableSortLabel-root.MuiTableSortLabel-active.MuiTableSortLabel-root.MuiTableSortLabel-active .MuiTableSortLabel-icon
我做了内联样式,还尝试使用 ThemeProvider 来覆盖它,但它没有用。另外我不知道它是从哪里带来排序图标的?因为它不在代码中。请帮我弄清楚这一点。
这是表头的代码。
return (
<TableHead>
<StyledTableRow>
<StyledTableCell padding="checkbox">
</StyledTableCell>
{headCells.map((headCell) => (
<StyledTableCell
key={headCell.id}
align={headCell.text ? 'left' : 'right'}
padding={headCell.disablePadding ? 'none' : 'default'}
sortDirection={orderBy === headCell.id ? order : false}
>
<TableSortLabel
style={{color: 'white'}}
active={orderBy === headCell.id}
direction={orderBy === headCell.id ? order : 'asc'}
onClick={createSortHandler(headCell.id)}
>
{headCell.label}
{orderBy === headCell.id ? (
<span className={classes.visuallyHidden}>
{order === 'desc' ? 'sorted descending' : 'sorted ascending'}
</span>
) : null}
</TableSortLabel>
</StyledTableCell>
))}
</StyledTableRow>
</TableHead>
);
}
编辑:
我将 TableRow 自定义为 StyledTableRow,将 TableCell 自定义为 StyledTableCell。
这是它的代码。(虽然不会影响 TableSortLabel)
const StyledTableCell = withStyles((theme) => ({
head: {
backgroundColor: theme.palette.common.black,
color: theme.palette.common.white,
},
body: {
fontSize: 14,
},
}))(TableCell);
const StyledTableRow = withStyles((theme) => ({
root: {
'&:nth-of-type(odd)': {
backgroundColor: theme.palette.action.hover,
},
},
}))(TableRow);
解决方案
推荐阅读
- r - r 如何根据 Pr 值从 r 摘要(模型)中选择截距/变量
- python - ModuleNotFoundError:没有名为“samples.coco”的模块
- python-3.x - python3在命令中插入变量值
- react-native - BackHandler.exitApp() 时重置 Linking.getInitialURL()
- javascript - 我如何知道 Vue 应用程序是否是从 javascript 安装的?
- java - 杰克逊:反序列化 JSON 提取深度属性到父类
- python - 如何从一个文件中提取特定数据并将其添加到特定位置的另一个文件中?
- firebase - 使用 Cloud Firestore 更新数组中的数据
- ios - iOS:调用 AWS Amplify GET 时出现 IncompleteSignatureException
- algorithm - 对相邻值之间的增量进行编码的数据结构/编码是否有名称?