vuex报错: [vuex] Expects string as the type, but found undefined.
报错如图
检查了好久,发现
import * as types from '../mutation-types'
const actions = { add({commit}){ commit(types.ADD) } } const mutations = { [types.ADD](state){ state.count++ } }
这里的 [types.ADD] 如果换成
const actions = { add({commit}){ commit('ad') } } const mutations = { ad(state){ state.count++ } }
就不会报错
判断结果:[types.ADD]这里有问题,
于是 检查mutation-types.js文件
原来是ADD等号右边没有加引号的缘故。导致[types.ADD]的出错