functionf(){returnnewPromise((resolve,reject)=>{setTimeout(()=>{reject(0)},1000)})}asyncfunctionmain(){letfunc=[];try{func.push(f());for(letiof[1,2,3]){awaitf();}awaitPromise.all(func);}catch(e){console.log(e);}}main();為什么這樣會(huì)報(bào)Unhandledpromiserejection,難道f()在放進(jìn)func時(shí)就執(zhí)行了嗎,小白求解
小白,請(qǐng)教各位大佬!async/await catch不到錯(cuò)誤?十分感謝
白衣非少年
2019-09-26 09:48:26