Can I call commit from one of mutations in Vuex store

后端 未结 12 1069
醉酒成梦
醉酒成梦 2021-02-03 16:25

I have a vuex store, like following:

import spreeApi from \'../../gateways/spree-api\'
// initial state
const state = {
  products: [],
  categories: []
}

// mu         


        
12条回答
  •  孤街浪徒
    2021-02-03 17:22

    For the record. To call other mutations from a mutation method do it like this:

    const mutations = {
        mutationOne(state, payload){
            this.commit("mutationTwo", payload)
        },
        mutationTwo(state, payload){
            console.log("called from another mutation", payload)
        }
    }
    

提交回复
热议问题