vue版本2.2.2, vue版本2.2.1// actions代碼const actions = { updateUser ({ commit }, { username }) { console.log(arguments) commit(types.UPDATE_USER, { username }) },}// 組件中調(diào)用actionsthis.$store.dispatch({ type: 'updateUser', username: 'hhhh'})實(shí)際運(yùn)行,發(fā)現(xiàn)actions.updateUser方法接受到三個(gè)參數(shù),第三個(gè)是undefined報(bào)錯(cuò)信息:Uncaught Error: [vuex] Expects string as the type, but found undefined.why?
1 回答

回首憶惘然
TA貢獻(xiàn)1847條經(jīng)驗(yàn) 獲得超11個(gè)贊
{username}
應(yīng)該沒有括號(hào)吧 。{}
里好像包裹的是接收過來的context對(duì)象里的內(nèi)容,如commit,state,getters
updateUser ({ commit }, username){ // ... }
添加回答
舉報(bào)
0/150
提交
取消