-
Notifications
You must be signed in to change notification settings - Fork 1
/
C11_03.js
39 lines (33 loc) · 977 Bytes
/
C11_03.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import React, { Component } from 'react';
import {Redirect} from "react-router-dom";
class C11_03 extends Component {
constructor(props) {
super(props);
this.state = { };
}
login=(e)=>{
e.preventDefault();
let username=this.refs.username.value
if(username==='123'){
this.setState({
loginFlag:true
})
}
}
render() {
if(this.state.loginFlag){
return <Redirect to={{ pathname: "/" }} />;
}
return (
<div>
<h1>演示通过Redirect进行跳转</h1>
<form onSubmit={this.login}>
username:<input ref='username'/> 用户名为123,就进行跳转 <br/><br/>
password:<input ref='password'/> <br/><br/>
<input type='submit' value="登录" />
</form>
</div>
);
}
}
export default C11_03;