在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問(wèn)答/HTML/ vuex中使用action傳遞參數(shù)報(bào)錯(cuò)

vuex中使用action傳遞參數(shù)報(bào)錯(cuò)

在vuex相關(guān)配置如下


const mutations = {
    incrementment( state,payload ){
        state.numb+= payload.amount;
    },
    reducement( state ){
        state.numb-- ;
    },
    [SOME_MUTATION](){
        state.numb+=10.98 
    }
}

const actions = {
    actionIncrement({ commit }){
        commit('incrementment')
    }
}

const store = new Vuex.Store({
    state,
    getters,
    actions,
    mutations
})

然后在組件中調(diào)用

<button @click="actionHand()">Actions 按鈕</button>

actionHand(){
          this.$store.dispatch({
            type:'actionIncrement',
            amount:70
          })
        }

但是點(diǎn)擊時(shí)候報(bào)錯(cuò) Cannot read property 'amount' of undefined
求大佬解答

回答
編輯回答
神經(jīng)質(zhì)
const actions = {
    actionIncrement({ commit }, payload){
        commit('incrementment', payload)
    }
}
2018年8月5日 17:22