【发布时间】:2018-11-01 06:51:54
【问题描述】:
我目前正在尝试从以下位置使用 history.push() 对象: https://github.com/ReactTraining/history
点击浏览器的后退按钮时,我无法更改浏览器的最后一个 URL。
当我使用 history.push(...) 时,当前浏览器的 URL 会发生变化;有办法避免这种情况吗?或者只是使用窗口对象我可以做到这一点?
我的应用程序不是单页应用程序;代码:
import createHistory from 'history/createBrowserHistory';
const history = createHistory();
const testUrl = 'http://test.com'
history.push(testUrl);
window.addEventListener('popstate', (event) => {
history.go(testUrl);
});
【问题讨论】:
标签: reactjs browser react-router