我是 React 的新手,我对如何在 Material UI 中覆盖类有点困惑。我查看了这些示例并尝试模仿它,但它似乎并没有按照我的意愿去做。
基本上,在表格行悬停时,我想让它设置与当前所做的不同的背景颜色。
这是我的方法:
const styles = theme => ({
root: {
width: "100%",
marginTop: theme.spacing.unit * 3
},
table: {
minWidth: 1020
},
tableWrapper: {
overflowX: "auto"
},
hover: {
"&:hover": {
backgroundColor: 'rgb(7, 177, 77, 0.42)'
}
}
});
return <TableRow hover classes={{hover: classes.hover}} role="checkbox" aria-checked={isSelected} tabIndex={-1} key={n.row_id} selected={isSelected}>
{this.insertRow(n, isSelected, counter, checkbox)}
;
export default withStyles(styles)(EnhancedTable);
谢谢你的帮助!
原文由 Tim 发布,翻译遵循 CC BY-SA 4.0 许可协议
您应该将 TableRow 的键定义为类名,然后将悬停样式作为对象放在该类名上。
在另一个示例中,它将是这样的: