运行材质UI 1.0.0-beta.24

我正在使用createMuiTheme设置新主题:

import {createMuiTheme} from 'material-ui/styles';

const theme = createMuiTheme({
  typography: {
    fontSize: 16
  }
});

export default theme;


如何在这里直接访问要覆盖的主题?
我想这样做,这是行不通的:

import {createMuiTheme} from 'material-ui/styles';

const theme = createMuiTheme({
  typography: {
    fontSize: theme.typography.fontSize + 2
  }
});

export default theme;

最佳答案

您需要创建默认主题的实例,并在定义自己的主题时使用它:

import { createMuiTheme } from 'material-ui/styles';

const defaultTheme = createMuiTheme();

const theme = createMuiTheme({
  typography: {
    fontSize: defaultTheme.typography.fontSize + 2
  }
});

export default theme;

关于reactjs - 访问createMuiTheme中的先前主题变量,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/47977618/

10-11 06:15