react 前端框架中的 三层(service,model,index)具体操作
获取数据:
service层
export async function key(params) {
return request(`${URL_PREFIX}/getPublicKey`, {
method: 'POST', data: params,
});
}
model层
* key({payload}, {call, put}) {
const response = yield call(key, payload);
return response;
},
index 层
const setKey = () => {
props.dispatch({
type: 'userManager/key'
}).then((result) => {
localStorage.setItem('publicKey', result.key);
setPublicKeyVelue(result);
});
}