当我尝试在 Ionic 2 中的提示警报中使用基本警报时卡住了

  • 本文关键字:提示 Ionic ionic2 alert
  • 更新时间 :
  • 英文 :


我的问题很简单,但我找不到解决方案。我正在尝试在提示警报中显示基本警报以显示我输入的结果,但我不知道为什么我的应用程序卡住了。

这是我的代码的基本示例,当显示"重复的电子邮件"警报时它卡住了,当我单击确定按钮时我无法关闭它

let prompt = this.alertCtrl.create({
title: 'Replacement Email',
message: "Please enter your new email",
inputs: [{
type: 'email',
name: 'email',
placeholder: 'user1@gmail.com'
},
],
buttons: [
{
text: 'Cancel',
handler: data => {
console.log('Cancel clicked');
}
},{
text: 'Save',
handler: data => { 
if(data.email!=""){
if(data.email==this.userService.email){
let alert = this.alertCtrl.create({
title: "Duplicated email",
subTitle: "Please enter new email",
buttons: ['OK']
});
alert.present();
}
}
}
}
]
});
prompt.present();

我通过使用"超时"解决了这个问题,但我认为这个问题有更好的解决方案

let prompt = this.alertCtrl.create({
title: 'Replacement Email',
message: "Please enter your new email",
inputs: [{
type: 'email',
name: 'email',
placeholder: 'user1@gmail.com'
},
],
buttons: [
{
text: 'Cancel',
handler: data => {
console.log('Cancel clicked');
}
},{
text: 'Save',
handler: data => { 
if(data.email!=""){
if(data.email==this.userService.email){
let alert = this.alertCtrl.create({
title: "Duplicated email",
subTitle: "Please enter new email",
buttons: ['OK']
});
setTimeout(() => {
alert.present();
},250);
}
}
}
}
]
});
prompt.present();

最新更新