Skip to content

mixins with navigation guards should go after installing vue router #3143

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
lovetingyuan opened this issue Mar 13, 2020 · 3 comments
Closed

Comments

@lovetingyuan
Copy link

Version

3.1.6

Reproduction link

https://codesandbox.io/s/stupefied-river-6pyng

Steps to reproduce

use component route guard before vue-router installed.

Vue.mixin({
  beforeRouteUpdate(to, from, next) {
    next();
  }
});

Vue.use(Router)

What is expected?

Just no error or the document should indicate that user should not use component route guard mixins before vue-router is installed.

What is actually happening?

TypeError: Cannot read property 'apply' of undefined
    at boundRouteGuard (https://6pyng.csb.app/node_modules/vue-router/dist/vue-router.common.js:2297:20)

    at iterator (https://6pyng.csb.app/node_modules/vue-router/dist/vue-router.common.js:2160:7)

    at step (https://6pyng.csb.app/node_modules/vue-router/dist/vue-router.common.js:1886:9)

    at runQueue (https://6pyng.csb.app/node_modules/vue-router/dist/vue-router.common.js:1894:3)

    at HTML5History.confirmTransition (https://6pyng.csb.app/node_modules/vue-router/dist/vue-router.common.js:2187:3)

    at HTML5History.transitionTo (https://6pyng.csb.app/node_modules/vue-router/dist/vue-router.common.js:2074:8)

    at HTML5History.push (https://6pyng.csb.app/node_modules/vue-router/dist/vue-router.common.js:2405:10)

    at VueRouter.push (https://6pyng.csb.app/node_modules/vue-router/dist/vue-router.common.js:2820:18)

    at handler (https://6pyng.csb.app/node_modules/vue-router/dist/vue-router.common.js:1100:18)

    at invokeWithErrorHandling (eval at Qr (https://codesandbox.io/static/js/sandbox.37b4bff87.js:1:178758), <anonymous>:1859:26)

    at HTMLAnchorElement.invoker (eval at Qr (https://codesandbox.io/static/js/sandbox.37b4bff87.js:1:178758), <anonymous>:2184:14)

    at HTMLAnchorElement.original._wrapper (eval at Qr (https://codesandbox.io/static/js/sandbox.37b4bff87.js:1:178758), <anonymous>:7543:25)
@posva
Copy link
Member

posva commented Mar 13, 2020

A PR with a code sample at https://router.vuejs.org/guide/advanced/navigation-guards.html#global-before-guards noting that any mixing containing guards should go after installing vue router plugin would make sense.

This applies to any plugin that adds options to Vue because they often set the margin strategy

@goelrohan6
Copy link

Hey @posva can I pick this up

@posva
Copy link
Member

posva commented Jul 26, 2020

Yes

@posva posva changed the title Error: Cannot read property 'apply' of undefined mixins with navigation guards should go after installing vue router Aug 8, 2020
@posva posva closed this as completed in da28363 Aug 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants