cannot read property 'dispatch' of undefined in Vuex

后端 未结 10 703
囚心锁ツ
囚心锁ツ 2020-12-30 03:51

I\'m trying to perform a dispatch on \'logOutUser\' in vuex store, and i\'m getting the following error message in respone:

TypeError: Cannot read pro

10条回答
  •  独厮守ぢ
    2020-12-30 04:09

    On a other note

    firebase.auth.onAuthStateChanged(user => {
      if(!app){
        /* eslint-disable no-new */
        app = new Vue({
          el: '#app',
          router,
          store,
          components: { App },
          template: ''
        })
      }
    });
    

    I bet you have this piece of code out of some tutorial because i was in that situation too but it will make your applicaton a lot slower on page reload because it will rerender everything everytime again.

    I suggest you to use the onAuthStateChanged Event in your router (yes thats possible) and then check there for possible route blocks or not, will be a lot faster.

    Im not home for code examples but i can send some later today if you want.

提交回复
热议问题