Call an action from within another action

廉价感情. 提交于 2019-12-03 02:30:53

问题


I have the following setup for my actions:

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

I want to be able to call one action from within another, so in this example I want to be able to call get2() from within get1(). Is this possible, and if so, how can I do it?


回答1:


You have access to the dispatch method in the object passed in the first parameter:

get1: ({ commit, dispatch }) => {
  dispatch('get2');
},

This is covered in the documentation.



来源:https://stackoverflow.com/questions/45848974/call-an-action-from-within-another-action

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!