【发布时间】:2016-10-29 22:54:10
【问题描述】:
我是 reactjs 和 javascript 的新手。我正在尝试创建一个非常基本的登录和注册表单。当客户输入电子邮件和密码并单击“注册”时,该表格应将他带到下一个表格 - 这是联系信息表格。但是我的页面刷新并带我回到原始屏幕而不是联系信息屏幕。这是登录和联系信息的代码-
import React from 'react';
import {render} from 'react-dom';
import { ContactInfo } from './ContactInfo.jsx'
var App = React.createClass ({
handleClick: function(){
<ContactInfo new="new"/>;
},
render: function() {
return (<div>
<h1>Login</h1>
<form>
Email: <input type="text" name="email" method="get" />
<br />
<br />
Password: <input type="password" name="pwd" />
<br />
<a href=""><i>forgot password?</i></a>
<br /><br />
<button>Login</button>
<button onClick={this.handleClick}>Register</button>
</form>
</div>);
}
});
render(<App />, document.getElementById('app'));
和联系信息:
import React from 'react';
var ContactInfo = React.createClass({
render: function(){
return(
<div>
<form>
Name: <input type="text"/>
<br />
<br />
Phone: <input type="text"/>
<br />
Address:
Street <input type = "text" />
<br />
City <input type = "text" />
<br />
State <input type = "text" /><p> </p>zip <input type = "text" />
<br />
Country <input type = "text" />
<br /><br />
<button>Continue</button>
</form>
</div>);
}
});
export default ContactInfo;
【问题讨论】:
-
好的。所以我理解它的方式是 - 当有人点击注册按钮时,我的 handleClick 处理程序函数“调用”ContactInfo。通话后,ContactInfo 类应呈现相关表单。对?任何更正都非常感谢!
标签: javascript reactjs login