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
}
添加回答
舉報