H4r*_*4se 4 typescript reactjs material-ui
我尝试将 Material UI Dashboard 转换为 TypeScript。https://github.com/mui-org/material-ui/blob/master/docs/src/pages/page-layout-examples/dashboard/Dashboard.js
目前我面临的问题是导出仪表板时无法在 withStyles 函数上设置 CSS 样式定义。
const styles = (theme: Theme) => ({
root: {
display: 'flex',
},
toolbar: {
paddingRight: 24, // keep right padding when drawer closed
},
toolbarIcon: {
display: 'flex',
alignItems: 'center',
justifyContent: 'flex-end',
padding: '0 8px',
...theme.mixins.toolbar,
},
appBar: {
zIndex: theme.zIndex.drawer + 1,
transition: theme.transitions.create(['width', 'margin'], {
easing: theme.transitions.easing.sharp,
duration: theme.transitions.duration.leavingScreen,
}),
},
.....
});
Run Code Online (Sandbox Code Playgroud)
如果我理解正确的话,我需要这个主题参考来将样式调整为当前主题。但是调用 style 函数时如何获取当前主题呢?
export default withStyles(styles(/*WHAT TO PUT IN HERE?*/))(Dashboard);
Run Code Online (Sandbox Code Playgroud)
export default withStyles(styles)(Dashboard);
withStyles将确定是否需要使用主题来调用它。
withTheme或者withStyles(stylesObjectOrCreator, { withTheme: true })仅当您需要通过 props 访问theme组件内部时才需要。
| 归档时间: |
|
| 查看次数: |
7928 次 |
| 最近记录: |