-
Notifications
You must be signed in to change notification settings - Fork 433
vue-router integration fails on beforeRoute* guards #193
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
Comments
@ktsn I am lazy 😁 |
the solution would be to not register the guards on options.methods but directly on the options object itself, e.g.
And AFAIK, options.computed will also not be interpreted by vue-router. So these need to be registered directly as properties of the options object, too. |
router.ts still load the component before calling registerHook because all import statement will be hoisted and executed before all other statements. Please try separate the registerHook in another file and import it before the component as same as docs. |
@ktsn which is the example provided. will try. |
@ktsn now it works as expected. still trying to figure out why. is there some second stage processing in vue-router or vue-class-component? anyway, thanks for your incredible help figuring this out. perhaps it should be made more clear in the documentation that registering the guards in a separate module is a vital step. |
That would be reeeeaally great. I made the same mistake and spent a lot of time on this( |
See https://gist.github.com/silkentrance/9caa45481329f6ef911bd5eae5dbb7c3
See also #192 (comment) for more information.
The text was updated successfully, but these errors were encountered: