Form窗体
const {
onSubmit: handleUpdate,
onCancel: handleUpdateModalVisible,
createModalVisible,
values,
dispatch
} = props;
const [menuData, setMenuData] = useState([]);
useEffect(() => {
dispatch({
#注意这里必须有相应的model,test指的是model的名称,query指的是具体方法,不是说访问的test/query后台接口,后台没有这个接口
type: 'test/query',
payload: {
data: {"pageSize":"99999"},
}
}).then((data) => {
setMenuData(data.data || []);
console.log(data)
})
}, []);
model
export default {
namespace: 'test',
state: {
},
effects: {
*query({ payload }, { call }) {
const response = yield call(query, payload);
return response;
},
},
};
最终service
export async function query(params?: TableListParams) {
return request('/xxxx/test/listPage', {
method: 'POST',
data: {
...params
},
})
}