
用 beforeUpdate 还是 watch $route,这两种方式是不是等价的?
1 ss098 2019-04-26 21:23:50 +08:00 watch $route 才是用来监听变化的吧,beforeUpdate 其他情况也会触发。 |
2 ss098 2019-04-26 21:23:50 +08:00 watch $route 才是用来监听变化的吧,beforeUpdate 其他情况也会触发。 |
3 ghostheaven OP @ss098 哪些情况? |
4 ss098 2019-04-26 21:58:50 +08:00 |
5 Everyman 2019-04-26 23:01:07 +08:00 应该使用 Vue Router 的导航守卫吧。 https://router.vuejs.org/guide/advanced/navigation-guards.html#global-before-guards 例如,在 Electron 中不能直接看到 chrome 的当前 URL,所以我就用 Vue Router 的 `router.afterEach` 每次路由变化后在 console 打印当前路由信息,以验证路由没错误。 |
6 ghostheaven OP |