React工作50:解决异步执行顺序问题

    this.props.dispatch({
          type: 'activity/addActivityPopup',
          payload: params,
          callback: (res) => {
            if (res.returnCode === 0) {
              message.success('新增成功');
              if (flag === true) {
                this.props.dispatch({
                  type: 'activity/publishActivityPopup',
                  payload: { codeList: [res.data] },
                  callback: (res) => {
                    openTab(this.props, `/management/frameList/index`);
                    refreshPage(this.props, `/management/frameList/index`);
                  },
                });
              } else {
                openTab(this.props, `/management/frameList/index`);
                refreshPage(this.props, `/management/frameList/index`);
              }
            } else {
              message.error(res.returnMsg);
            }
          },
        });

posted @ 2022-07-23 22:31  前端导师歌谣  阅读(148)  评论(0)    收藏  举报