日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

vuex报错: [vuex] Expects string as the type, but found undefined.

發布時間:2025/3/20 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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.的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。