router.push make beforeeach run twice #1742
-
Reproductionreproduce easily Steps to reproduce the bug1、declare beforeeach with router and embed console.log in it for log. Expected behaviorlog is printed once after router.push. Actual behaviorlog is printed twice after router.push. Additional informationNo response |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
I find stable steps to reproduce. the additioal information is that the element which trigger router.push behavior is a |
Beta Was this translation helpful? Give feedback.
-
There is also the initial navigation that makes the An another possibility is you put the |
Beta Was this translation helpful? Give feedback.
There is also the initial navigation that makes the
router.beforeEach()
run once for the initial navigation (app.use(router) on client). The second log comes from your router.push()An another possibility is you put the
router.beforeEach()
within a component'ssetup
, so every time that component is mounted, a new navigation guard is added without removing the other one when unmounting.