停止警报Ctrl 自动触发取消在 Ionic 2 中



我有一个警报控制器,当触发时,它会打开然后立即关闭,而无需我执行任何操作。

let alert = this.alertCtrl.create({
title: 'Requires Login',
message: 'Please register or log in to add to cart.',
buttons: [
{
text: 'Cancel',
handler: () => {
console.log('Cancel clicked');
}
},
{
text: 'Login',
handler: () => {
this.logOut();
}
}
]
});
alert.present();

我找不到任何问题,我想知道是什么导致了这个问题?当我通过手机运行应用程序时,出现错误,但是当我通过浏览器运行它时,没有错误。

这是我当前项目中的一个工作示例

logout() {
let confirm = this.alertCtrl.create({
title: 'Confirm',
message: 'Are you sure you want to logout?',
buttons: [
{
text: 'No',
handler: () => { }
},
{
text: 'Yes',
handler: () => {
this.removeNotificationRegistrationAndLogOut(LoginPage, true);
}
}
]
});
confirm.present();
}

最新更新