在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML/ react進(jìn)入頁面獲取數(shù)據(jù)時(shí)一直觸發(fā)action,異步請求出不來,頁面卡死

react進(jìn)入頁面獲取數(shù)據(jù)時(shí)一直觸發(fā)action,異步請求出不來,頁面卡死

react進(jìn)入頁面獲取數(shù)據(jù)時(shí)一直觸發(fā)action,異步請求出不來,頁面卡死,異步請求是用的dva

index.js

componentDidMount() {
    const { dispatch } = this.props;
    dispatch({
      type: 'stock/webRelease',
    });
};

model

*webRelease({ payload }, { call, put }) {
      yield put({
        type: 'changeLoading',
        payload: true,
      });
      let dataList = {};
      dataList.serviceParams = {...payload};
      const response = yield call(getWebRelease, dataList);
      let pageSize = 10;
      if (dataList.serviceParams.pageSize) {
        pageSize = response.datas.pageSize * 1;
      };
      if(response.resultCode === 0) {
        yield put({
          type: 'save',
          payload: {
            list: response.datas.carList,
            pagination: {
              total: response.datas.total,
              pageSize,
              current: parseInt(dataList.serviceParams.curPage, 10) || 1,
            }
          }
        });
      }else{
        message.error(response.message, /* duration */3)
      };
      yield put({
        type: 'changeLoading',
        payload: false,
      });
},

services

export async function getWebRelease(params) {
  params.serviceMethod = "getAllCarToPublish";
  params.serviceName = "carService";
  params.market = window.localStorage.getItem('market');
  params.user = window.localStorage.getItem('user');
  params.token = window.localStorage.getItem('token');

  return request('api/webRelease', {
    method: 'POST',
    body: params,
  });
}

圖片描述

回答
編輯回答
心沉

你的代碼中service中的requestbody,應(yīng)該是:

return request('api/webRelease', {
    method: 'POST',
    body: JSON.stringify(params),
  });

除些沒看出什么問題。
既然使用的dva,那就不要在didMountdispatch了,直接在model中的discriptions中監(jiān)聽路由來獲取數(shù)據(jù)。

2017年7月30日 22:13
編輯回答
笨尐豬

我剛碰到類似問題,我的是引入dva-loading導(dǎo)致的,刪除后就沒事了。

2017年8月18日 12:52