dvaJS Model之间的调用

 

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);

 

posted @ 2019-08-16 15:32  victorlyw  阅读(4638)  评论(0编辑  收藏  举报