【发布时间】:2020-04-09 10:25:27
【问题描述】:
使用这个工具https://react-theming.github.io/create-mui-theme/ 我得到了一个 js 文件和一个 json 文件,如上述主题生成器页面所述,在各自的路径中:
// src/ui/theme/index.js
/* src/ui/theme/theme.json */
现在,当我将文件扩展名留给 js 时,它们可以正常工作。一旦我尝试使用 js 作为 tsx 文件,编辑器就会开始抱怨。我还通过 tsconfig 文件中的 CRA Typescript 完成了所有必要的设置。此页面还需要配置https://material-ui.com/guides/typescript/
当我尝试这个时它不起作用,如果我遗漏了什么,有什么想法吗?
// My amended index.tsx file
import { createMuiTheme } from '@material-ui/core/styles';
const palette = {
primary: { main: '#3f51b5' },
secondary: { main: '#f50057' }
};
const themeName = 'San Marino Razzmatazz Sugar Gliders';
export default createMuiTheme({ palette, themeName });
theme.json 也没有被我触及。 对不起,我还在学习,如果这是一个界面问题以及如何使用它,有什么想法吗? 谢谢!
【问题讨论】:
标签: javascript reactjs typescript material-ui create-react-app