无法发布错误反应js

Bok*_*oky 4 reactjs react-router

我得到一个空白页面,错误为无法 POST /registration/step-two

我正在尝试创建多步注册。我的主要组件的渲染功能如下:

render() {
    const languageReg = this.props.currentLanguage.default.registrationPage;


    let stepOne = (this.props.params.id == 'step-one') ? <RegistrationFormStepOne actionSaveUser={this.props.actionSaveUser} currentLanguage={languageReg}/> : "";
    let stepTwo = (this.props.params.id == 'step-two') ? <RegistrationFormStepTwo actionSaveUser={this.props.actionSaveUser} currentLanguage={languageReg}/> : "";

    return (
        <div className="sidebar-menu-container" id="sidebar-menu-container">

            <div className="sidebar-menu-push">

                <div className="sidebar-menu-overlay"></div>

                <div className="sidebar-menu-inner">
                    <div className="contact-form registrationForm">
                        <div className="container">
                            <div className="row">
                                <div className="col-md-10 col-md-offset-1 col-md-offset-right-1">
                                    {stepOne}
                                    {stepTwo}
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    );
}
Run Code Online (Sandbox Code Playgroud)

在 RegistrationFormStepOne 中,我具有单击功能,如下所示:

handleClick(){
    let data = {name: "stepOne", values: [this.state.user]};
    this.context.router.push("/registration/step-two");
}
Run Code Online (Sandbox Code Playgroud)

当我点击这个按钮时,网址就像它应该的样子,http://localhost:3000/registration/step-two但我收到了Cannot POST /registration/step-two错误。

当我直接输入http://localhost:3000/registration/step-two 时,它工作正常。

我正在使用reactNoConfiguration 应用程序

有什么建议吗?

Bok*_*oky 9

问题出在句柄点击功能上。我忘了防止违约。我把它改成:

handleClick(event){
     event.preventDefault();
     let data = {name: "stepOne", values: [this.state.user]};
     this.context.router.push("/registration/step-two");
}
Run Code Online (Sandbox Code Playgroud)

它奏效了。