- 业务需求:点击按钮,跳转到另一个页面(或者另一个组件)
A页面有一个按钮,点击按钮,跳到B页面 - 实现思想:使用路由跳转
import { Link } from 'react-router-dom'
将跳转按钮用link包住 to=‘路径’,state,携带的参数(要在路由下面配置好)
<Link
to={{
pathname: '',
state: {
id: 'create'
}
}}
>
<Button type="primary" onClick={this.handlerOk}>
创建
</Button>
</Link>
- 获取携带参数:
this.props.location.state.operateType