Bel*_*ier 5 networking ionic-framework ionic4
我的应用程序找不到互联网时如何退出?我希望它向用户显示一个对话框“无互联网连接”,按下一个确定按钮,它会关闭应用程序。谢谢
Pie*_*ina 11
this.platform.exitApp() 似乎已从离子版本 4 中删除。尝试:
navigator['app'].exitApp();
Run Code Online (Sandbox Code Playgroud)
页。
vd_*_*ani -1
尝试下面的代码this.platform.exitApp();
constructor(public platform : Platform){
this.platform.registerBackButtonAction(() => {
if (this.alertShown == false) {
this.presentConfirm();
this.alertShown = true
}
}, 0);
}
presentConfirm() {
let alert = this.alertCtrl.create({
title: 'Confirm',
message: 'Do you want to exit?',
buttons: [
{
text: 'Cancel',
role: 'cancel',
handler: () => {
console.log('Cancel clicked');
this.alertShown = false;
}
},
{
text: 'Yes',
handler: () => {
console.log('Yes clicked');
this.platform.exitApp();
}
}
]
});
alert.present().then(() => {
//this.alertShown=true;
});
}
Run Code Online (Sandbox Code Playgroud)