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

Cannot read property 'dispatch' of undefined at createRouterMiddleware #168

Open
jinghun1999 opened this issue May 20, 2021 · 4 comments
Open

Comments

@jinghun1999
Copy link

TypeError: Cannot read property 'dispatch' of undefined
    at createRouterMiddleware (vuex-oidc.esm.js?3d72:656)
    at iterator (vue-router.esm.js?1e6f:1959)
    at step (vue-router.esm.js?1e6f:1733)
    at runQueue (vue-router.esm.js?1e6f:1741)
    at HTML5History.confirmTransition (vue-router.esm.js?1e6f:1988)
    at HTML5History.transitionTo (vue-router.esm.js?1e6f:1890)
    at VueRouter.init (vue-router.esm.js?1e6f:2541)
    at Vue.beforeCreate (vue-router.esm.js?1e6f:553)
    at invokeWithErrorHandling (vue.runtime.esm.js?6e6d:1854)
    at callHook (vue.runtime.esm.js?6e6d:4213)

使用的是vue-element-admin框架,弄了半天了也没发现问题所在,就一直报这个错

@xukingnie
Copy link

router.beforeEach(async(to, from, next) => {
return vuexOidcCreateRouterMiddleware(store, 'oidcStore')(to, from, next)
})

@perarnborg
Copy link
Owner

@jinghun1999 Do you need any help with this? Or did the comment from @xukingnie help you?

Unfortunately you need to ask your question in English in order for me to help you out.

@baboon-king
Copy link

@jinghun1999
I also encountered this problem, "store" is null in some cases.
I did not find the reason, but I did it successfully.
you try ?

if (store) {
  router.beforeEach(vuexOidcCreateRouterMiddleware(store, 'oidcStore'))
}

@baboon-king
Copy link

router.beforeEach(async(to, from, next) => {
return vuexOidcCreateRouterMiddleware(store, 'oidcStore')(to, from, next)
})

this successful! thanks

router.beforeEach(async (to, from, next) => {
  return vuexOidcCreateRouterMiddleware(store, 'oidcStore')(to, from, next)
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants