dvaJS Model之间的调用

ぐ巨炮叔叔 提交于 2019-11-27 13:01:26

 

const Model: ModelType = {
  namespace: 'namesps',

  state: {
    data: {}
  },

  effects: {
    *fetch({ payload, callback }, { call, put, select }) {
      const res = yield call(queryApplyInvoiceInfo, payload);
      if (!res || !res.data) return;
      const total = yield select((state) => state.user.currentUser )
      console.log(total);
      yield put({
        type: 'change',
        payload: res
      })
      if (callback) callback();
    }
  },

  reducers: {
    change (state, { payload }) {
      return {
        data: (state && state.data) || {
          list: [],
          pagination: {}
        }
      }
    }
  }
};

export default Model;
// 选择 state + '全局属性名(namespace)' + state属性名
const total = yield select((state) => state.user.currentUser )
console.log(total);

 

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