![](/img/trans.png)
[英]How does google maps change its URL without reloading and without using the history API?
[英]Is there a method to change the URL without reloading or making changes to the history?
我有一个React应用程序,用户单击一个按钮,然后返回一个随机项目,我想从该项目中删除一个属性并将其附加到URL。 但是,我不希望页面重新加载。 虽然我可以使用history.replace / history.push来更新URL,但问题是,如果用户单击返回,则它们将返回到最后一页,该页面根据redux-store中的先前值正确呈现。 ,但网址会落后。
例如,如果用户在myapp / item6上并单击“后退”按钮,他们将返回到myapp / item5,但URL不会更改以反映此情况。
当前,使用react-router和withRouter。
<Link
to={{
pathname: '/somelocation',
state: { from: props.location }
}}
/>
然后在您的后退按钮中
<Link to={props.location.state.from}>
Back
</Link>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.