1、使用vuex 在組件里使用this.$store.commit()提示不是function在enter.vue中 created () {
this.$store.commit('changeIndexConf', {
isTab: true,
isBack: false,
title: ''
});
}3.store.jsimport Vue from 'vue';import Vuex from 'vuex';
Vue.use(Vuex)const store = new Vuex.Store({
state: {
comm: {
loading: false,
login: {
memberId: ''
},
indexConf: {
isTab: false
}
}
},
mutations: {
changeIndexConf: (state, data) => {
Object.assign(state.comm.indexConf, data);
}
}
});
export default store4、提示enterpiseList.vue?c518:15 Uncaught TypeError: this.$store.commit is not a function
2 回答

陪伴而非守候
TA貢獻(xiàn)1757條經(jīng)驗(yàn) 獲得超8個(gè)贊
可能你沒有注冊(cè)成全局的。
//render page const root = new Vue({ router, store, //注冊(cè)成全局的 ...Page }).$mount('#root');
在組件中使用建議:
methods: { ...mapMutations('filter', ['updateIndustry','resetData']) }
這樣就可以和組件內(nèi)部函數(shù)一樣調(diào)用了。
添加回答
舉報(bào)
0/150
提交
取消