与默认的“MuiAppBar-colorPrimary”相比,您的 CSS("makeStyles-appBar") 似乎是最后应用的,
针对您的情况的几种解决方案,
1。使用样式属性
<AppBar position="fixed" style={{ color: 'black', z-index: 1201, background-color: 'red'}}>
2。在你的 CSS 上使用 !important - 不可取
appBar: {
backgroundColor: 'red !important',
color: 'black !important',
zIndex: (theme.zIndex.drawer + 1) + ' !important'
}
参考 -
Transparent AppBar in material-ui (React)
https://material-ui.com/api/app-bar/
TypeScript - 带有装饰器的参考如下,
import * as React from 'react';
import { withStyles, WithStyles } from 'material-ui/styles';
import { StyledComponent } from 'material-ui';
type C = 'root' | 'foo';
interface P { options?: string[]; }
interface S { open: boolean; }
@withStyles((theme) => ({
root: {},
foo: {},
}))
class Component extends React.Component<P & WithStyles<C>, S> {
render() {
return (
<div className={this.props.classes.root} />
);
}
}
export default Component as StyledComponent<P, C>; // type assertion
没有装饰器
const SelectedMenu = withStyles(theme => ({
root: {
maxWidth: 360,
width: '100%',
backgroundColor: theme.palette.background.paper,
},
}))<P>(class extends React.Component<P & WithStyles<C>, S> {
来源 - https://github.com/mui-org/material-ui/issues/8598