第一种传参方式,动态路由传参
<Link to='/home/dx'>首页</Link>
<Route path="/home/:name" component={Home}>
第二种传参方式,search传参
<Link to='/home?name=dx'>首页</Link>
this.props.location.search
this.props.location.query
当页面跳转到UserPage页面之后,取出传过来的值
export default class UserPage extends React.Component{
constructor(props){
super(props);
}
render(){
return(<div>this.props.match.params.name</div>)
}
}