Skip to content

beforeRouteLeave invoked twice when redirecting inside of beforeRouteEnter #2102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
gzzhanghao opened this issue Mar 13, 2018 · 2 comments
Closed
Labels

Comments

@gzzhanghao
Copy link

Version

3.0.0

Reproduction link

https://jsfiddle.net/Jason_Daurus/vv79u55j/

Steps to reproduce

Click at "link-b" in the fiddle, you'll have "A:beforeRouteLeave" logged twice in browser's console.

What is expected?

A:beforeRouteLeave should not be invoked after B:beforeRouteEnter

What is actually happening?

it does :-(

@cxyao
Copy link

cxyao commented Jun 8, 2018

I meet the same issue.
I'm using redirect to fixed the twice invoke.
I think it's a bug of VueRoute
If you are chinese, i hope this link will be helpful https://www.cnblogs.com/Amar/p/9154452.html

@posva posva changed the title beforeRouteLeave invoked twice when replacing path in target view beforeRouteLeave invoked twice when redirecting inside of beforeEnter Mar 26, 2019
@posva posva changed the title beforeRouteLeave invoked twice when redirecting inside of beforeEnter beforeRouteLeave invoked twice when redirecting inside of beforeRouteEnter Mar 26, 2019
@posva posva added the bug label Mar 26, 2019
@posva
Copy link
Member

posva commented Apr 11, 2019

I'm taking a second look at this, the problem is that when we redirect we are triggering a new navigation, so it makes sense to invoke the guard once again with a different to parameter.
What I think would help here is being able to know if the navigation is a redirection to bypass the guard which you can follow at #1822

@posva posva closed this as completed Apr 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants