同时使用 async/await
和 .then().catch()
有什么害处吗,比如:
async apiCall(params) {
var results = await this.anotherCall()
.then(results => {
//do any results transformations
return results;
})
.catch(error => {
//handle any errors here
});
return results;
}
await
将Promise链的最终值传递给result
变量。 - yqlim