Call an action from within another action

后端 未结 5 731
一个人的身影
一个人的身影 2021-01-30 05:03

I have the following setup for my actions:

get1: ({commit}) => {
  //things
  this.get2(); //this is my question!
},
get         


        
5条回答
  •  无人及你
    2021-01-30 05:28

    for actions that does not require payload

    actions: {
        BEFORE: async (context, payload) => {
        },
        AFTER: async (context, payload) => {
            await context.dispatch('BEFORE');
        }
    }
    

    for actions that does require payload

    actions: {
        BEFORE: async (context, payload) => {
        },
        AFTER: async (context, payload) => {
            var payload = {}//prepare payload
            await context.dispatch('BEFORE', payload);
        }
    }
    

提交回复
热议问题