任何人都可以建議如何遷移到新組件單擊提交按鈕?我正在使用react.Included電子郵件字段和一個提交按鈕做一個簡單的登錄頁面,試圖如果我輸入電子郵件n點擊提交密碼組件出現。即與gmail登錄相同。遷移到新組件點擊提交按鈕在反應
0
A
回答
1
創建主要組件如下。
export default class Index extends React.Component{
constructor(props) {
super(props);
this.state = {
currentStep : 1,
};
this.changeStep = this.changeStep.bind(this);
}
loadSteps() {
switch(this.state.currentStep) {
case 1:
return (<EmailView />);
case 2:
return (<PasswordView />);
default:
return (<EmailView />);
}
}
changeStep(step) {
this.setState({ currentStep : step});
}
render() {
return (
<div className="login-steps-container">
{this.loadSteps()}
</div>
);
}
}
,並創建兩個用於電子郵件字段和密碼的步驟子組件,
Email.js
export default class Email extends React.Component{
constructor(props) {
super(props);
}
render() {
return (
<div className="email-step" >
<input type="text" className="email-field">
<input type="button" value="Go to" onClick="this.props.changeStep.bind(this, 2)">
</div>
);
}
}
Password.js
export default class Password extends React.Component{
constructor(props) {
super(props);
}
render() {
return (
<div className="password-step" >
<input type="password" className="password-field">
<input type="button" value="Login" >
</div>
);
}
}
+1
太棒了!謝謝...還可以請你指導我如何設置主要測試電子郵件和密碼...例如:我想要電子郵件作爲[email protected]和密碼爲12345678 –
+0
你是什麼意思的主要測試電子郵件。你是指文本框內的佔位符文本嗎?或文本框內的默認電子郵件? –
+0
我的意思是測試郵件..i.e我希望頁面進一步只有當我輸入[email protected]和密碼爲12345678 –
相關問題
- 1. 上點擊提交按鈕移動itsplace
- 2. 在點擊提交按鈕時提交
- 3. VBA提交按鈕點擊
- 4. 當點擊提交按鈕
- 5. 點擊提交按鈕
- 6. 點擊提交後按鈕
- 7. jQuery:ajax,點擊提交按鈕
- 8. 提交按鈕點擊
- 9. 點擊提交按鈕後點擊f5
- 10. 點擊提交按鈕後沒有任何反應
- 11. 表單提交,雖然點擊按鈕不是提交按鈕
- 12. 按鈕點擊提交只在Firefox
- 13. 如何在點擊提交按鈕
- 14. 爪哇 - SWT - 在點擊提交按鈕
- 15. jQuery的點擊()在提交按鈕
- 16. 反應原生按鈕點擊移動到另一個屏幕
- 17. 移動設備上的提交按鈕不點播後點擊
- 18. 提交按鈕被禁用,直到點擊另一個按鈕
- 19. 提交按鈕覆蓋的所有按鈕點擊事件
- 20. 如何在按鈕點擊反應時將一個組件移動到另一個組件?
- 21. 反應路由器v4組件未載入按鈕提交
- 22. 點擊反應呈現新組件
- 23. 形式輸入按鍵提交或點擊提交按鈕
- 24. 滾動頁面嵌套產生反應按鈕組件點擊
- 25. 無法提交表單,而點擊提交按鈕在EJS
- 26. JQuery上點擊或提交按鈕
- 27. 點擊後隱藏提交按鈕
- 28. 防止快速提交按鈕點擊?
- 29. HtmlUnit按鈕點擊不提交
- 30. 多提交按鈕點擊問題?
我有點困惑,但如果你只是想要兩步登錄,那麼在提交電子郵件後更改組件狀態並呈現密碼輸入。 –
是啊我嘗試使用它的工作狀態,但有一些問題......也有任何方法來設置主要的用戶名和密碼?例如我想將它設置爲[email protected]和密碼爲123456 –