首页 文章

'material-ui'不包含名为'withStyles'的导出

提问于
浏览
0

我的package.json看起来像这样 . 该应用程序工作正常,直到不久前我突然得到这个错误 .

"@material-ui/icons": "1.0.0-beta.42",
"chartist": "0.10.1",
"classnames": "2.2.5",
"material-ui": "1.0.0-beta.41",
"npm-run-all": "4.1.2",
"perfect-scrollbar": "1.3.0",
"react": "16.2.0",
"react-chartist": "0.13.1",
"react-dom": "16.2.0",
"react-google-maps": "9.4.5",
"react-router-dom": "4.2.2",
"react-scripts": "1.0.17",
"react-swipeable-views": "0.12.12"

我的组件看起来像这个导入React来自“react”;从“material-ui”导入{withStyles,Card,CardHeader,CardContent,CardActions,Typography};从“prop-types”导入PropTypes;

import profileCardStyle from "assets/jss/material-dashboard-react/profileCardStyle";

function ProfileCard({ ...props }) {
const { classes, subtitle, title, description, footer, avatar } = props;
return (
<Card className={classes.card}>
<CardHeader
classes={{
root: classes.cardHeader,
avatar: classes.cardAvatar
}}
avatar={<img src={avatar} alt="..." className={classes.img} />}
/>
<CardContent className={classes.textAlign}>
{subtitle !== undefined ? (
<Typography component="h6" className={classes.cardSubtitle}>
{subtitle}
</Typography>
) : null}
{title !== undefined ? (
<Typography component="h4" className={classes.cardTitle}>
{title}
</Typography>
) : null}
{description !== undefined ? (
<Typography component="p" className={classes.cardDescription}>
{description}
</Typography>
) : null}
</CardContent>
<CardActions className={classes.textAlign + " " + classes.cardActions}>
{footer}
</CardActions>
</Card>
);
}

ProfileCard.propTypes = {
classes: PropTypes.object.isRequired,
title: PropTypes.node,
subtitle: PropTypes.node,
description: PropTypes.node,
footer: PropTypes.node,
avatar: PropTypes.string
};

export default withStyles(profileCardStyle)(ProfileCard);

1 回答

  • 1

    您需要导入MUI的 withStyles

    import { withStyles } from 'material-ui/styles'
    

相关问题