路由传参的三种方式
1、params参数
<Link to='/demo/test/tom/18'>详情</Link>
<Route path='/demo/test/:name/:age' component={Test} />
const {name, age} = this.props.match.params;
2、search参数
<Link to='/demo/test?name=tom&age=18'>详情</Link>
<Route path='/demo/test' component={Test} />
this.props.location.search
3、state参数
<Link to={{pathname: '/demo/test', state: {name: 'tom', age: 18}}}>详情</Link>
<Route path='/demo/test' component={Test} />
this.props.location.state
编程式路由导航
this.props.history.push(`/home/message/detail/${id}/${title}`);
this.props.history.push(`/home/message/detail?id=${id}&title=${title}`);
this.props.history.push('/home/message/detail', {id, title});