My store/index.js looks like this:
const store = new Vuex.Store({
modules: {
app,
user,
},
state: {
token: getToken(),
hasLogin: false,
},
mutations: {
...rootMutations,
},
actions: {
...rootActions,
},
})
export default store
The content of store/modules/user.js is as follows:
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
const store = new Vuex.Store({
namespaced: true,
state: {
phone: '',
},
mutations: {
setUserInfo(
{ state },
{ phone },
) {
// ...
state.phone = phone | state.phone
},
},
})
export default store
There seems to be an issue with one of the actions:
In rootActions.js:
const actions = {
getUserInfo: async function(store) {
const { commit, state } = store
console.log(store)
return await new Promise((resolve, reject) => {
// A lot of request code here, save results in user/setUserInfo
commit('login')
commit('user/setUserInfo', {
phone: r.phone,
})
})
},
}
However, I encountered an error related to unknown mutation type:
[vuex] unknown mutation type: user/setUserInfo(env: macOS,mp,1.05.2106300; lib: 2.17.0)
I'm unsure why I am unable to access mutations in the user module. I've tried various samples but none seem to work for me. Can someone please help me solve this issue?