why i am getting error of “cannot read property 'state' of undefined ” in vue js

后端 未结 1 1810
后悔当初
后悔当初 2021-01-27 03:27

my store/index.js is :

import Vue from \'vue\'
import Vuex from \'vuex\'
Vue.use(Vuex)
export default
new Vuex.Store({
  st         


        
相关标签:
1条回答
  • 2021-01-27 03:59

    Are you sure you have injected store to the component like this:

     let store = new Vuex.Store({
        state: {
        name: 'Alicia Vikander',
        age: 20,
        dob: '20/08/1990'
      },
      mutations: {
        updateName(state, name) => {
          state.name = name
        }
      }
    })
    
    new Vue({
      store,
      el: '#app',
      render: h => h(App)
    });
    
    0 讨论(0)
提交回复
热议问题