长话短说,Typescript 抱怨property classes每个 Material-UI 组件都缺失。换句话说,Typescript 强制该classes属性存在于几乎每个 Material-ui 组件中。这是使用 webpack 编译期间的错误消息ts-loader,
我有以下代码,
标头.tsx
import AppBar from 'material-ui/AppBar';
import * as React from 'react';
import { withStyles } from 'material-ui/styles/index';
import Toolbar from 'material-ui/Toolbar';
import Typography from 'material-ui/Typography';
const decorate = withStyles((theme) => ({
header: {
paddingTop: theme.spacing.unit,
width: '100%',
},
}));
const AppBarTypographyStyle = {
color: 'white',
fontSize: '1.6rem',
};
const Header = decorate(({classes}) => (
<header>
<AppBar position="static" classes={{root: classes.header}}>
<Toolbar>
<Typography …Run Code Online (Sandbox Code Playgroud)