请教个问题,在一个页面的 created 钩子函数里面做了个 this.$route.push, 此时仍然会把生命周期执行完,有没有什么办法直接跳转到新的页面,不执行接下来的 mounted 啥的。
请教个问题,在一个页面的 created 钩子函数里面做了个 this.$route.push, 此时仍然会把生命周期执行完,有没有什么办法直接跳转到新的页面,不执行接下来的 mounted 啥的。
|
airylandJan 13, 2020
1
router.beforeEach
|
|
shintendoJan 13, 2020
2
你需要路由守卫而不是生命周期钩子
|
|
shadowyueJan 13, 2020
4
你为啥希望正常的 mounted 不触发呢?
一般遇到比较奇怪的操作,先想想是不是有哪里不合理不合适呗 |
|
duuuJan 13, 2020
6
你这个跳转逻辑应该写在前一个页面里判断跳转到 A 还是 B,而不是先跳转到 A 里面判断要不要留下来还是跳转到 B
|
|
jevonszmxJan 13, 2020
7
|
|
shellusJan 13, 2020
8
在 data 里面放个 continue: true
在 created 里面 this.continue=false; 然后在 mountedd 里面 if(this.continue === false){return;} |