Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/473.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何修复';TypeError:无法读取属性';风格';未定义的';使用材质ui转换时出错_Javascript_Reactjs_Material Ui - Fatal编程技术网

Javascript 如何修复';TypeError:无法读取属性';风格';未定义的';使用材质ui转换时出错

Javascript 如何修复';TypeError:无法读取属性';风格';未定义的';使用材质ui转换时出错,javascript,reactjs,material-ui,Javascript,Reactjs,Material Ui,我试图在react应用程序中使用转换,但每次我尝试使用任何转换模块时,都会出现以下错误:“TypeError:无法读取未定义的属性'style'” (匿名函数) node_modules/@material ui/core/esm/Fade/Fade.js:83 我尝试过不使用es6类风格的方法,这实际上解决了问题,但我想使用es6类 我认为这与我在顶部定义的styles变量有关,如下所示: const styles = theme => ({ typography: {

我试图在react应用程序中使用转换,但每次我尝试使用任何转换模块时,都会出现以下错误:“TypeError:无法读取未定义的属性'style'”

(匿名函数) node_modules/@material ui/core/esm/Fade/Fade.js:83

我尝试过不使用es6类风格的方法,这实际上解决了问题,但我想使用es6类

我认为这与我在顶部定义的styles变量有关,如下所示:

const styles = theme => ({
    typography: {
        marginTop: theme.spacing(2)
    }
});

class IndexPage extends Component {
    constructor(props) {
        super(props);
        this.state = {
            checked: false,
        }
    }

    render() {
        const {classes} = this.props;

        return (
            <React.Fragment>
                <Typography className={classes.typography} align={"center"} variant={"h2"} component={"h2"}>
                    <Fade in={this.state.checked}>
                        Welcome to my Portfolio!
                    </Fade>
                </Typography>
            </React.Fragment>
        )
    }
}

IndexPage.propTypes = {
    styles: PropTypes.object.isRequired,
};

export default withStyles(styles)(IndexPage);
constyles=theme=>({
排版:{
marginTop:主题。间距(2)
}
});
类IndexPage扩展组件{
建造师(道具){
超级(道具);
此.state={
勾选:假,
}
}
render(){
const{classes}=this.props;
返回(
欢迎来到我的投资组合!
)
}
}
IndexPage.propTypes={
样式:PropTypes.object.isRequired,
};
导出默认样式(样式)(IndexPage);

我希望排版标签内的文本淡入,但应用程序崩溃。

淡入
排版组件:


欢迎来到我的投资组合!
;
例如:

导出默认函数App(){
返回(
欢迎
);
}

我认为过渡需要一个子组件。当我尝试淡入多个div时发生的
const styles = theme => ({
    typography: {
        marginTop: theme.spacing(2)
    }
});

class IndexPage extends Component {
    constructor(props) {
        super(props);
        this.state = {
            checked: false,
        }
    }

    render() {
        const {classes} = this.props;

        return (
            <React.Fragment>
                <Typography className={classes.typography} align={"center"} variant={"h2"} component={"h2"}>
                    <Fade in={this.state.checked}>
                        Welcome to my Portfolio!
                    </Fade>
                </Typography>
            </React.Fragment>
        )
    }
}

IndexPage.propTypes = {
    styles: PropTypes.object.isRequired,
};

export default withStyles(styles)(IndexPage);