【发布时间】:2017-12-30 06:37:33
【问题描述】:
我正在尝试使用 overriding by classes 方法覆盖 Material-UI v1 组件的样式。
当我尝试覆盖嵌套属性时,例如 root 键上的 :hover 伪类,我收到以下警告:
Warning: Material-UI: the key `.MyButton-root-w:hover` provided to
the classes property object is not implemented in Button.
You can only overrides one of the following:
参见示例:
import React from "react";
import { createStyleSheet, withStyles } from "material-ui/styles";
import Button from "material-ui/Button";
const buttonStyle = createStyleSheet("MyButton", {
root: {
backgroundColor: "#f99",
"&:hover": {
backgroundColor: "#99f"
}
}
});
export default withStyles(buttonStyle)(Button);
或者在https://codesandbox.io/s/gRgGrYvr查看它的实际应用
由于示例按钮在悬停时确实会获得不同的背景颜色,我想知道这是否是 Material-UI 中的问题,或者我还没有完全掌握如何覆盖其样式。
【问题讨论】:
标签: reactjs material-ui