2 回答

TA贡献1818条经验 获得超3个赞
你有没有尝试过:
onClick={() => dispatch({
type: 'GET_INFO',
url: 'your/url/goes/here'
})}
export function* getInfoSaga(action) {
while (true) {
yield take(mutations.GET_INFO);
const url1 = `${action.url}/api/getInfo/1-100`;
const logInfo = yield axios.get<any>(url1).then(response => response);
yield put(mutations.setInfo(logInfo.data.data));
}
}

TA贡献1797条经验 获得超4个赞
更新:传递有效载荷并仅从“take”分配返回值
onClick={() => dispatch({
type: 'GET_INFO',
payload: {
key1: value1
// other values here
}
})}
export function* getInfoSaga() {
const action = yield take(mutations.GET_INFO);
// action.payload.key1
}
添加回答
举报