我尝试监听history.pushState和history.replaceState,
在vue项目中
1. 第一次打开页面history.replaceState执行了两次
2. 刷新页面执行了一次history.replaceState
3. 页面通过$router.push切换执行了一次history.pushState和history.replaceState

在react项目中
1. 第一次打开不会执行这两个
2. 刷新不会执行
3. 使用useHistory的push,history.pushState执行
4. 使用useHistory的replace,history.replaceState执行

我又尝试监听hash
在vue项目使用的hash路由,但不管页面怎么跳转hashchange都不执行

我想知道vue的执行为什么这么奇怪,然后hash为啥无法监听[可怜]
展开
4