Skip to content
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

Route guards - beforeRouteLeave not working inside a component #433

Closed
LorenRd opened this issue Jul 8, 2020 · 2 comments
Closed

Route guards - beforeRouteLeave not working inside a component #433

LorenRd opened this issue Jul 8, 2020 · 2 comments
Labels
needs reproduction We need a runnable reproduction from the OP

Comments

@LorenRd
Copy link

LorenRd commented Jul 8, 2020

image
Using nuxt and composition-api plugin.

The execution is not going inside, beforeRouteLeave is never called even if is a console.log it doesn't work.
The behaviour is the same if is not async.

@antfu antfu added the needs reproduction We need a runnable reproduction from the OP label Jul 9, 2020
@BradenM
Copy link

BradenM commented Aug 9, 2020

I am also witnessing this behavior while using the composition-api without nuxt.

I also attempted this, which also fails:

...
setup(props, { root }) {
  ....
  root.$options.beforeRouteLeave = (to, from, next) => { // also fails }
  ...
}

}

@posva
Copy link
Member

posva commented Aug 9, 2020

beforeRoute* guards must go on view components that are associated with a route. You cannot add it to root

Closing as no reproduction has been provided and the problem likely comes from what I said above

@posva posva closed this as completed Aug 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs reproduction We need a runnable reproduction from the OP
Projects
None yet
Development

No branches or pull requests

4 participants