我从A页面带参数跳转到B页面
this.props.history.push({ pathname: '/send_msg', state: { query: obj } })
此时在B页面能取到this.props.location.state
但是刷新B页面,this.props.location.state就变成了undefined,求解如何处理?
我从A页面带参数跳转到B页面
this.props.history.push({ pathname: '/send_msg', state: { query: obj } })
此时在B页面能取到this.props.location.state
但是刷新B页面,this.props.location.state就变成了undefined,求解如何处理?
4 回答1.6k 阅读
2 回答1.1k 阅读✓ 已解决
2 回答2.6k 阅读
1 回答952 阅读✓ 已解决
1 回答681 阅读✓ 已解决
2 回答842 阅读✓ 已解决
2 回答1k 阅读
刷新肯定会报错,因为你的参数是从前一个页面带过来的,正确的做法是用路由参数,可以放在 query 里边,这样参数保存在 url 里,就不怕刷新了