VUEX的函数代码:
let mutations = {
changeChooseModule (state, module) {
state.chooseModule[module.id] = module //增加
},
delChooseModule (state, id) {
state.chooseModule.map((v, i) => {
if (v.id === id) {
state.chooseModule.splice(i, 1) //删除
}
})
},
delChooseModuleAll (state, moduleNull) {
state.chooseModule = moduleNull // 清空
}
}
通过commit触发 改变
this.$store.commit('changeChooseModule', this.moduleLists[i])
this.$store.commit('delChooseModule', i)
this.$store.commit('delChooseModuleAll', [])