return and next behave differently in the beforeEach guard. #2335
Replies: 3 comments
-
|
Beta Was this translation helpful? Give feedback.
0 replies
-
![]() |
Beta Was this translation helpful? Give feedback.
0 replies
-
sorry The return statement is called at an inappropriate point. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Reproduction
production
Steps to reproduce the bug
Expected behavior
I'm encountering an unexpected behavior with Vue Router's beforeEach guard. Despite following the documented approach of returning to.fullPath to initiate a redirect, the navigation isn't occurring as anticipated. I've discovered that employing next within the guard is the sole method to successfully trigger a redirect.
Actual behavior
Additional information
I'm encountering an issue with Vue Router's beforeEach guard. I'm expecting return to.fullPath to initiate a redirect, but the guard isn't being re-evaluated and the route doesn't match. Switching to next(to) resolves the issue. Could you please explain the underlying mechanism and why this behavior occurs?
vue-router version: 4.0.16
vue version: 3.2.45
Beta Was this translation helpful? Give feedback.
All reactions