1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
'/test': { component: dynamicWrapper( app, ['testModel'], () => import('../routes/Test') ), name: 'Test', },
import { connect } from 'dva'; @connect(({ testModel }) => ({ ...testModel }))
import request from '@/utils/request'; export async function GetNameList(params) { return request(`http://localhost:8000/api/test/GetNameList`, { method: 'POST', body: params }); }
import * as service from '../../services/test' export default { namespace: "testModel", state: { nameList: ["Jerry"] }, effects: { getNameList({ payload, callback }, { call, put }) { const result = yield call(service.GetNameList, payload); yield put({ type: 'returnData', payload: result, }); if (callback) { callback(result); } } }, reducers: { returnData(state, action) { const result = action.payload; let dataSource = result.data; return { ...state, dataSource, }; }, }, };
|