demo如下:
跳转
history.push({pathname:'/july/detail',state:{param:'我是需要传递的参数'}});
获取:
const { param } = this.props.history.location.state;
console.log(param)
在React应用中,使用`history.push`方法可以实现页面跳转,并传递状态数据。例如,将`param`值为我是需要传递的参数通过state属性添加到路径/july/detail中。然后,在目标组件中,可以通过`this.props.history.location.state`获取传递的参数。
demo如下:
跳转
history.push({pathname:'/july/detail',state:{param:'我是需要传递的参数'}});
获取:
const { param } = this.props.history.location.state;
console.log(param)
1万+
895

被折叠的 条评论
为什么被折叠?