路由跳转
- API跳转
this.props.history.push('/course')
- NavLink
<NavLink to="/course"></NavLink>
- Link
<Link to="/course"></Link>
- a标签
<a href="#/course"></a>
路由传参
- API传参
this.props.history.push({
pathname: "/course",
test: 'test',
state: {name: 'tom'}
})
this.props.location.test
this.props.location.state
- 查询字符串传参
<NavLink to="/course?name=tom">NavLink跳转</NavLink>
this.props.location.search
- 动态路由传参
<Route path="/sc/:id" component={Course}></Route>
<NavLink to="/sc/2">NavLink跳转-动态路由</NavLink>
this.props.match.params.id