3
我需要調用vuex模塊它不起作用。我已經看過文檔,但仍然無效。希望可以有人幫幫我。Vuex模塊突變
const stateLocations ={
state: {
provinces: {},
cities: {}
},
mutations: {
provinces(state, payload){
state.provinces = payload
}
}
}
const store = new Vuex.Store({
modules: {
locations: stateLocations
}
})
我的代碼來調用突變
created(){
var store = this.$store
axios.get('api/provinces')
.then(function(response){
store.state.locations.commit('provinces', response.data)
})
.catch()
}
這一個不工作store.state.locations.commit('provinces', response.data)
TY
由於它的工作原理就像一個魅力... – Rbex