本文介绍了无法发布错误反应js的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

render() {const languageReg = this.props.currentLanguage.default.registrationPage;让 stepOne = (this.props.params.id == 'step-one') ?<RegistrationFormStepOne actionSaveUser={this.props.actionSaveUser} currentLanguage={languageReg}/>:"";让 stepTwo = (this.props.params.id == 'step-two') ?<RegistrationFormStepTwo actionSaveUser={this.props.actionSaveUser} currentLanguage={languageReg}/>:"";返回 (<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="容器"><div className="row"><div className="col-md-10 col-md-offset-1 col-md-offset-right-1">{步骤1}{第二步}

);}

在 RegistrationFormStepOne 中,我有如下点击功能:

handleClick(){让数据 = {name: "stepOne", values: [this.state.user]};this.context.router.push("/registration/step-two");}

当我点击这个按钮时,网址应该是 http://localhost:3000/registration/step-two 但我得到 Cannot POST/registration/第二步错误.

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

我正在使用 reactNoConfiguration 应用程序

有什么建议吗?

解决方案

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

handleClick(event){event.preventDefault();让数据 = {name: "stepOne", values: [this.state.user]};this.context.router.push("/registration/step-two");}

它奏效了.

I get an blank page with an error Cannot POST /registration/step-two.

I'm trying to create multistep registration. Render function of my main component is as follows:

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>
    );
}

In RegistrationFormStepOne I have function on click as follows :

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

When I click on this button, the url is like it should be http://localhost:3000/registration/step-two but I'm getting Cannot POST /registration/step-two error.

When I type direct http://localhost:3000/registration/step-two it works fine.

I'm using reactNoConfiguration App

Any advice?

解决方案

The problem was in the handle click function. I forgot to prevent default. I changed it to :

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

and it worked.

这篇关于无法发布错误反应js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-15 14:15