這是我的代碼:
Promise.all([
await dispatch(a()),
await dispatch(b()),
await dispatch(c()),
await dispatch(d())
]).then(console.log).catch(console.log);
我得到這個日志:
0: undefined
1: undefined
2: undefined
3: undefined
我想得到這些資料,Promise我必須使用await
uj5u.com熱心網友回復:
Promise.all 將在其中的所有異步都解決后解決,因此您不需要在其中等待,因為它是隱式等待,因此請洗掉 promis.all 中的 await fom 并再次檢查。
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/463787.html
標籤:javascript 反应 下一个.js
