即
async asyncfunction(){
try{
await method1();
await method2();
}
catch(error){
console.log(error);
}
}
Run Code Online (Sandbox Code Playgroud)
给定method1()和method2()是异步函数.每个await方法都应该有一个try/catch块吗?是否有更清晰的方式来写这个?我试图避免'.then'和'.catch'链接.