async的用法,它作为一个关键字放到函数前面,用于表示函数是一个异步函数,因为async就是异步的意思, 异步函数也就意味着该函数的执行不会阻塞后面代码的执行。
async presentAlertPrompt(status: any, type: any, id: any, userId: any, idId: any, extendId1: any, extendId2: any) {
const alert = await this.alertController.create({
header: '请输入拒绝理由',
inputs: [
{
id: 'msg',
name: 'msg',
type: 'text',
placeholder: '请输入拒绝理由!'
}
],
buttons: [
{
text: '取消',
role: 'cancel',
handler: () => {
console.log('Cancel clicked');
}
},
{
text: '确定',
handler: data => {
const rn = (data.msg).trim();
if (rn === '') {
super.showToast(this.toastCtrl, '拒绝理由不可以为空哦');
return;
}
this.message = rn;
this.changeStatus2(status, type, id, userId, idId, extendId1, extendId2, this.message);
}
}
]
});
await alert.present();
}
拓展:
回调地狱 https://www.jianshu.com/p/39adf6ab8ad1