我收到一个错误的空白页无法发布/注册/第二步。
我试图创建多步注册。我的主要组件的渲染功能如下:
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>
);
}
在RegistrationFormStepOne中我点击了如下功能:
handleClick(){
let data = {name: "stepOne", values: [this.state.user]};
this.context.router.push("/registration/step-two");
}
当我点击此按钮时,该网址应该是http://localhost:3000/registration/step-two
,但我收到Cannot POST /registration/step-two
错误。
当我直接键入http://localhost:3000/registration/step-two时,它可以正常工作。
有什么建议吗?
答案 0 :(得分:4)
问题在于句柄点击功能。我忘了防止违约。我改成了:
handleClick(event){
event.preventDefault();
let data = {name: "stepOne", values: [this.state.user]};
this.context.router.push("/registration/step-two");
}
它有效。这是我的愚蠢错误。