解决vuex 状态管理mutations报错为:"[vuex] unknown mutation type: VIWE_NAV"
报错截图:
我的解决思路:
1.先检查gettes方向获取与actions提交是否畅通,同时专注检查code是否输错。
2.我查了别人多数是“”在vuex中没有mutation,有的是mutations,把上面的mutation修改为mutations即可“”这样的问题
3.我这个问题同样是没有找到“”VIWE_NAV/VIWE_FOOT“”,我前面定义的是“”VIEW_NAV/VIEW_FOOT“”
问题源码:actions.js
import { VIEW_NAV, VIEW_FOOT, VIEW_LOADING, UPDATA_HOME } from "./types"
export default {
[VIEW_NAV]: ({ commit, state }, payload) => { commit('VIWE_NAV', payload) },
[VIEW_FOOT]: ({ commit, state }, payload) => { commit('VIWE_FOOT', payload) },
[VIEW_LOADING]: ({ commit, state }, payload) => { commit('VIEW_LOADING', payload) },
[UPDATA_HOME]: ({ commit, state }, payload) => {
commit('VIWE_NAV', payload)
},
}
解决:因为没有找到VIEW
![](https://img2020.cnblogs.com/blog/2530319/202109/2530319-20210908090633536-1569556435.png)