Referenceerror State Is Not Defined In Vuex Store
My vuex store looks like this but when calling addCustomer I get ReferenceError: state is not defined: import Vue from 'vue'; import Vuex from 'vuex'; Vue.use(Vuex); export defau
Solution 1:
You're missing the state
in addCustomer function parameters (addCustomer: function (customer)
) :
import Vue from 'vue';
import Vuex from 'vuex';
Vue.use(Vuex);
export default new Vuex.Store({
state: { customers: [] },
mutations: {
addCustomer: function (state,customer) {
state.customers.push(customer); // error is thrown here
}
}
});
Post a Comment for "Referenceerror State Is Not Defined In Vuex Store"