我正在尝试使用覆盖类方法覆盖Material-UI v1 组件的样式。
当我尝试覆盖嵌套属性时,例如根键上的: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 中的问题,或者我是否还没有完全掌握如何覆盖其样式。