单击设备后退按钮关闭应用程序,而不是返回到android 9中的上一页

时间:2019-07-04 10:49:07

标签: ionic-framework

在ionic框架中,单击“后退”按钮可关闭应用程序,而不是返回上一页。仅在android 9中才发生。在其他android版本中工作正常。

我已经在app.component.ts中写了这些代码

this.platform.backButton.subscribe(() => {
      if (this.router.isActive('/home', true) && this.router.url === '/home') {
        navigator['app'].exitApp();
      }
   });

1 个答案:

答案 0 :(得分:0)

这是解决方案:在homepage.ts中可能有用

ionViewDidEnter(){

this.subscription = this.platform.backButton.subscribe(()=> {

navigator ['app']。exitApp(); });

}

ionViewWillLeave(){

this.subscription.unsubscribe();

}

相关问题