首页 > 解决方案 > 我的 ionic 4 应用程序在单击后退按钮时关闭了几天。现在它不工作

问题描述

我正在开发一个 ionic4 应用程序。注销后,我使用 this.navController.navigateRoot 方法重定向到登录页面。通过单击移动返回按钮来关闭应用程序,我使用了以下代码。之后它工作了几天,现在我必须发布这个应用程序的更新,如果点击移动后退按钮它没有关闭应用程序,而是重定向到上一个打开的屏幕。谁能帮我解决这个问题?离子版本:5.2.3 代码:

ionViewDidEnter() {
    this.subscription = this.platform.backButton.subscribe(async () => {
        navigator['app'].exitApp();
    });
}

ionViewWillLeave() {
    this.subscription.unsubscribe();
}

标签: ionic-frameworkionic4

解决方案


试试这种方式删除async ()

constructor(public myplatform: Platform)
{}

ionViewDidEnter()
{
      this.backbButtonSubscription = this.myplatform.backButton.subscribe(()=>{
          //handle whatever You want
      });
}

ionViewWillLeave(){
      this.backbButtonSubscription.unsubscribe();
}

希望这会帮助你链接


推荐阅读