首先前一个页面跳转:
previewItem = id => {
router.push(`/sample/detail/${id}`);
};
然后后面页面获取id 数值
dispatch({
type: 'rule/fetchSampleDetail',
id: match.params.id,
});
然后传递给 rule
* fetchSampleDetail({ id }, { call, put }) {
// console.log(payload);
const response = yield call(getSampleDetail, id);
yield put({
type: 'show',
payload: response,
});
},
最后发送给request 向后端服务器请求数据:
export async function getSampleDetail(id) {
// console.log(id);
return request(`/api/samples/${id}/`, {
headers: {
Authorization: "JWT ".concat(String(localStorage.getItem('auth-token')))
}
});
}
网友评论