【发布时间】:2021-10-07 12:47:11
【问题描述】:
我在项目 MUI v5.0.2 上使用。一周前我的项目运行正常(没有错误),但今天突然出现了一个错误(代码没有变化)
错误:
TypeError: Cannot read properties of undefined (reading 'drawer')
代码:
const useStyles = makeStyles((theme) => ({
...
appBar: {
zIndex: theme.zIndex.drawer + 1, //this line showed at error message
transition: theme.transitions.create(['width', 'margin'], {
easing: theme.transitions.easing.sharp,
duration: theme.transitions.duration.leavingScreen,
}),
},
...
}));
Visual Studio 代码也说:
Property 'zIndex' does not exist on type 'DefaultTheme'
我试过this solution,但没有帮助
也许有人知道如何解决它?
UPD:我试图回滚到之前的提交,但同样的错误发生在那里,虽然这之前没有发生过
主题对象:
const theme = createTheme({
palette: {
primary: {
light: '#757ce8',
main: '#3f50b5',
dark: '#002884',
contrastText: '#fff',
},
secondary: {
light: '#ff7961',
main: '#f44336',
dark: '#ba000d',
contrastText: '#000',
},
},
});
【问题讨论】:
标签: javascript reactjs material-ui