问题描述
正在处理一个项目并陷入问题:
Working on a Project and stuck in an Issue:
硬件后退按钮重新加载应用程序(我在此应用程序中使用 Angular Router).
Hardware Back Button Reloading Application (I am using Angular Router in this application).
我的退出应用程序代码:
My Code to Exit Application:
ionViewDidEnter(){
this.subscription = this.platform.backButton.subscribe(()=>{
navigator['app'].exitApp();
});
}
ionViewWillLeave(){
this.subscription.unsubscribe();
}
虽然相同的逻辑在其他应用程序中工作.但在这个应用程序中,它重新加载了应用程序而不是退出它.
While same logic Working in other applications. but in this application its reloading the application not exiting it.
P.S:我也试过把它放入 platform.ready()
但没有运气.
P.S: i have also tried it to put in platform.ready()
but no luck.
推荐答案
已解决:
正如 @rtpHarry 模板的 SideMenu/Tabs 所提到的那样,它具有导致应用程序在根页面上自行重新加载的历史记录.我能够通过清除历史记录来解决这个问题.
As Mention by @rtpHarry template of SideMenu / Tabs have History which leads application to Reload it self on root page. i was able to solve this by clearing History.
ionViewDidEnter(){
navigator['app'].clearHistory();
}
在您的根页面上只需清除您的历史记录,您的硬件后退按钮将关闭应用程序而不是重新加载它.
on Your Root Page just Clear your history and your Hardware Back Button will close the Application instead of Reloading it.
这篇关于Ionic 4:硬件返回按钮重新加载应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!