方式一
// 不推荐使用
this.props.history.push("/user?id=123");
方式二 页面刷新参数不会丢失
this.props.history.push("/user/123");
路由配置
<Route exact path='/user/:id' component={User}></Route>
接收参数方法
this.props.match.params
方式三 页面刷新参数不会丢失
推荐使用
this.props.history.push({
pathname: "/apple",
state: {
id: 123,
}
});
接收参数方法
this.props.location.state