vuex报错: [vuex] Expects string as the type, but found undefined.
生活随笔
收集整理的這篇文章主要介紹了
vuex报错: [vuex] Expects string as the type, but found undefined.
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
報(bào)錯(cuò)如圖
檢查了好久,發(fā)現(xiàn)
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++} }就不會(huì)報(bào)錯(cuò)
判斷結(jié)果:[types.ADD]這里有問(wèn)題,
于是 檢查mutation-types.js文件
?
原來(lái)是ADD等號(hào)右邊沒(méi)有加引號(hào)的緣故。導(dǎo)致[types.ADD]的出錯(cuò)
?
轉(zhuǎn)載于:https://www.cnblogs.com/wang715100018066/p/9805975.html
總結(jié)
以上是生活随笔為你收集整理的vuex报错: [vuex] Expects string as the type, but found undefined.的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: linux环境下查看项目内存情况
- 下一篇: 手把手教你做一个react-redux-