This commit is contained in:
2022-06-15 23:42:32 +08:00
parent 3320d88acf
commit ecae5af30f
3 changed files with 8 additions and 5 deletions
+3 -2
View File
@@ -6,8 +6,9 @@
this.props.children
Switch 只匹配第一次
exact 严格匹配
Redirect
Redirect 重定向/默认匹配项
路由嵌套
路由传参
params传参,需要声明接收
serach传参,无需声明接收
serach传参,无需声明接收
state
+3 -1
View File
@@ -1,12 +1,14 @@
/*
* @Author: chenxuan
* @Date: 2022-06-05 16:55:45
* @LastEditTime: 2022-06-05 17:17:46
* @LastEditTime: 2022-06-15 22:05:46
* @LastEditors: chenxuan
*/
import React,{Component} from 'react'
class Money extends Component{
render(){
console.log(this.props.location.state)
return (
<div>
<h2>this is Money</h2>
+2 -2
View File
@@ -1,7 +1,7 @@
/*
* @Author: chenxuan
* @Date: 2022-05-22 22:25:38
* @LastEditTime: 2022-06-12 23:18:11
* @LastEditTime: 2022-06-15 23:42:13
* @LastEditors: chenxuan
*/
import React,{Component} from 'react'
@@ -17,7 +17,7 @@ class Home extends Component{
<ul className='homeNav'>
<Link to="/home/news/chenxuan/123" children="新闻"/>
<Link to="/home/car/?name=chenxuan&id=123456" children="汽车" />
<Link to="/home/money" children="财经" />
<Link to={{pathname:'/home/money',state:{name:"陈轩",age:"18岁",sex:"男"}}} children="财经" />
</ul>
<div className='homeContent'>
<Route path="/home/news/:name/:id" component={New} />