这个问题的目的是了解幕后发生的事情。每次找到代码时,makeStyles()我都会感觉自己只是在进行纯复制粘贴,而不了解引擎盖下发生的事情。所以我想在这里发布一个问题,以便有人可以帮助我。
我已经在许多React应用程序中看到以下类型的代码。我很想知道当我们打电话给时发生了什么makeStyles()。因此,我跳入了它的定义,但我不明白它的含义。有人可以帮助我了解如何阅读/理解它。
我在这里了解的是,我正在传递一个名为的函数theme。通过该函数后,我不知道发生了什么。我也很高兴有人能帮助我解决这个问题。
// Calling makeStyles()
const useStyles = makeStyles(theme => ({
root: {
display: 'flex',
},
drawer: {
[theme.breakpoints.up('sm')]: {
width: drawerWidth,
flexShrink: 0,
},
},
appBar: {
marginLeft: drawerWidth,
[theme.breakpoints.up('sm')]: {
width: `calc(100% - ${drawerWidth}px)`,
},
},
menuButton: {
marginRight: theme.spacing(2),
[theme.breakpoints.up('sm')]: {
display: 'none',
},
},
toolbar: theme.mixins.toolbar,
drawerPaper: {
width: drawerWidth,
},
content: {
flexGrow: 1,
padding: theme.spacing(3),
},
}));
//definition of makeStyles()
import { Theme as DefaultTheme } from …Run Code Online (Sandbox Code Playgroud) 如何更改/自定义 Material-UI 表(排序和选择类型)中选定行的默认颜色?默认情况下,它是辅助(红色)颜色(此处为Codesandbox: https: //codesandbox.io/s/3sjxh)。如何将其更改为自定义颜色,或至少更改为主要颜色(蓝色),如新测试版本中所示 ( https://next.material-ui.com/components/tables/#main-content ) (v5 )。