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

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