ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
BrowserRouter跳转时的url是不带`#`的 ![](https://box.kancloud.cn/245c61f8c3555997fb3d3da989cc815b_770x462.png) 实现基础 pushState是异步的,so,如果你直接在下面go,此时还没有记录,也就不会触发popState ``` window.onpopstate = function(event) { console.log(history.state) }; // location.href = '#123' history.pushState({a:1},'1','?123') history.pushState({b:1},'2','?234') // history.go(-1); //这样是无效的 document.documentElement.onclick = function(e){ history.go(-1) } ``` >pupstate就会改变url,但不会立刻跳转,需要go()才会