gpt4 book ai didi

reactjs - 访问 createMuiTheme 中以前的主题变量

转载 作者:行者123 更新时间:2023-12-03 13:16:09 24 4
gpt4 key购买 nike

运行Material 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com