使用语义UI反映多步骤表单

问题描述 投票:2回答:1

我刚刚用React掌握了语义UI,并且正在关注这个tutorial

虽然不错,但使用的“开关案例”却发出警告“预期的默认情况”。

我假设这是一种更简单的方法来完成并消除警告信息?

render(){
        const {step} = this.state;
        const { firstName, lastName, email, age, city, country } = this.state;
        const values = { firstName, lastName, email, age, city, country };
        switch(step) {
        case 1:
            return <UserDetails 
                    nextStep={this.nextStep} 
                    handleChange = {this.handleChange}
                    values={values}
                    />
        case 2:
            return <PersonalDetails 
                    nextStep={this.nextStep}
                    prevStep={this.prevStep}
                    handleChange = {this.handleChange}
                    values={values}
                    />
        case 3:
            return <Confirmation 
                    nextStep={this.nextStep}
                    prevStep={this.prevStep}
                    values={values}
                    />
        case 4:
            return <Success />
        }
    }
reactjs semantic-ui
1个回答
1
投票

像创建案例一样添加此项。 :

default:
            return <UserDetails 
                    nextStep={this.nextStep} 
                    handleChange = {this.handleChange}
                    values={values}
                    />

`

这是默认情况,当值不是1时调用,也不是2,3和4。

© www.soinside.com 2019 - 2024. All rights reserved.