This commit is contained in:
2022-08-25 01:05:33 +08:00
parent 5f9b4d50b9
commit 875040745f
3 changed files with 10 additions and 5 deletions
+5 -1
View File
@@ -16,4 +16,8 @@
10、exact属性严格匹配 to匹配path
<Route exact={true} path="/test" component={Test}/> to='/test/a/b' 此时to不能匹配path
<Route exact={false} path="/test" component={Test}/> to='/test/a/b' 此时可以匹配path
11、Redict重定向 兜底
11、Redict重定向 兜底
12、路由嵌套
13、路由传参 pathname
14、push与replace
15、witchRoute 使一般组件拥有路由组件的属性,返回值是一个新组件
+2 -2
View File
@@ -1,7 +1,7 @@
/*
* @Author: chenxuan
* @Date: 2022-05-22 21:48:34
* @LastEditTime: 2022-08-23 00:41:17
* @LastEditTime: 2022-08-23 01:06:03
* @LastEditors: chenxuan
*/
import React,{Component} from 'react'
@@ -29,7 +29,7 @@ class App extends Component{
<Route path="/about" component={About}/>
<Route path="/home" component={Home}/>
<Route path="/code" component={Test1}/>
<Route exact={true} path="/test" component={Test}/>
<Route exact={false} path="/test" component={Test}/>
<Redirect to="/home" />
</Switch>
</div>
+3 -2
View File
@@ -1,7 +1,7 @@
/*
* @Author: chenxuan
* @Date: 2022-05-22 22:25:38
* @LastEditTime: 2022-06-19 19:36:21
* @LastEditTime: 2022-08-25 00:42:10
* @LastEditors: chenxuan
*/
import React,{Component} from 'react'
@@ -17,7 +17,8 @@ class Home extends Component{
this.props.history.replace("/code/car/?name=chenxuan&id=123456")
}
replace3=()=>{
this.props.history.replace({pathname:"/code/money",state:{name:"陈轩",age:"18岁",sex:"男"}})
// this.props.history.replace({pathname:"/code/money",state:{name:"陈轩",age:"18岁",sex:"男"}})
this.props.history.replace('/code/money',{name:"陈轩",age:"19岁",sex:"男"})
}
push1=()=>{
this.props.history.push("/code/news/chenxuan/123")