码迷,mamicode.com
首页 > Web开发 > 详细

dvaJS Model之间的调用

时间:2019-08-16 15:46:27      阅读:506      评论:0      收藏:0      [点我收藏+]

标签:mod   ret   amp   callback   cal   return   script   sel   bsp   

 

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

 

dvaJS Model之间的调用

标签:mod   ret   amp   callback   cal   return   script   sel   bsp   

原文地址:https://www.cnblogs.com/victorlyw/p/11364237.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!