dva icon indicating copy to clipboard operation
dva copied to clipboard

怎么拿到整个state状态树啊?

Open jiangbo2015 opened this issue 9 years ago • 2 comments

用redux工具查看每个路由下的状态,状态都是对应model里面的状态,如果我要用其他model里的状态,怎么获取啊

jiangbo2015 avatar Apr 17 '17 01:04 jiangbo2015

effects里面的Generator函数里面可以获得select函数,select函数能获取整个store里面的state。例子:

    *getUserList(action, { call, put, select }) {
      yield put({
        type: 'changeLoading',
        payload: true,
      });
      const query = yield select(state => state['UserManage/UserList'].query);
      console.log(query);
      const res = yield call(UserListService.getUserList, query);
      yield put({
        type: 'getUserListReducer',
        payload: res.data,
      });
    },

MinLeeV5 avatar Apr 17 '17 01:04 MinLeeV5

太好了,就是她

jiangbo2015 avatar Apr 17 '17 02:04 jiangbo2015