Vuex: Cannot read property ‘$store’ of undefined

solved: https://stackoverflow.com/questions/46335667/vuex-cannot-read-property-store-of-undefined

You’re using a javascript function instead of an arrow function. 

js function (not work):

axios({

}).then(function(data){
    this.$store.dispatch('loginSucc', user)
})

arrow function:

axios({

}).then((data) => {
    this.$store.dispatch('loginSucc', user)
})
jimschenchen

jimschenchen

Share

Leave a Reply