ionic-framework - 异步和等待的目的?
问题描述
我曾尝试研究 async 和 await 的使用,但我不明白。用外行的话来说它有什么用?我们可以在哪里使用它?
就像在这个例子中一样,什么是异步或函数试图做什么。
异步和等待的示例
resetPassword(email: string) {
this.angularFire.sendPasswordResetEmail(email).then(async () => {
let alert = await this.alertCtrl.create({
header: 'Reset Password',
message: 'Password reset email sent! Check your inbox.',
buttons: [{
text: "OK",
handler: () => {
this.navCtrl.pop();
}
}]
})
await alert.present();
}).catch(async () => {
let alert = await this.alertCtrl.create({
header: 'Alert',
message: "Email or account does not exist. Please try again with a valid email or account!",
buttons: [{
text: "OK",
handler: () => { }
}]
})
await alert.present();
});
}
解决方案
推荐阅读
- android - 从 json 中检索对象
- python - JMeter 和 Python 瓶 - 不关闭套接字
- javascript - 即使使用 babel 编译,ES6 for of 语句也会出错
- angular - 处理角度 4 中的验证
- c# - 为 Web Deploy 设置数据库提供程序
- django - 在 django REST API 中删除图像链接的主机名
- android - TextView 链接下划线问题
- r - 如何在 ggMarginal 中使用频率
- fonts - Ubuntu 18.04 LTS 字体无法正确呈现
- webrtc - Webrtc 应用程序仅在禁用防火墙时工作