vuex报错: [vuex] Expects string as the type, but found undefined.
生活随笔
收集整理的這篇文章主要介紹了
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]的出錯
?
轉載于:https://www.cnblogs.com/wang715100018066/p/9805975.html
總結
以上是生活随笔為你收集整理的vuex报错: [vuex] Expects string as the type, but found undefined.的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux环境下查看项目内存情况
- 下一篇: 手把手教你做一个react-redux-