首页  >  问答  >  正文

javascript - vuex中同级action 如何互相调用

getSitefind({ commit, state }, param) {
        http.get('acb', param)
        .then((res) => {
            const data = JSON.parse(res.data).result;
            commit('updateSitefind', data);
        });
    },
cancelHot({ commit, state }, param) {
        http.post(`bcd`, { data: param.data })
        .then((res) => {
            const code = JSON.parse(res.data);
            if (code.code === 1) {
                commit('hideModal');
                http.get(`${baseUrl}supplier/common/sitefind`, { params: param.params })
                .then((response) => {
                    const data = JSON.parse(response.data).result;
                    commit('updateSitefind', data);
                });
            } else {
                const params = {
                    color: 'danger',
                    content: '取消导航失败!请重新尝试!',
                    show: true,
                };
                commit('showModal', params);
            }
        });
    },

如图所示=-= 我现在只能在另外一个action中再调用一次之前的action有没有什么方法可以调用同级的actions?

巴扎黑巴扎黑2748 天前1622

全部回复(1)我来回复

  • 伊谢尔伦

    伊谢尔伦2017-04-11 12:23:48

    actions: {
      actionA ({ dispatch, commit }) {
        //...
      },
      actionB ({ dispatch, commit }) {
        return dispatch('actionA').then(() => {
          commit('someOtherMutation')
        })
      }
    }

    https://vuex.vuejs.org/zh-cn/...组合-actions

    回复
    0
  • 取消回复