This 问题及其答案 (复制如下)提供了一个在 Ionic 中处理后退按钮的解决方案,但该解决方案仅在直接从其他页面推送时才有效app.component
,在这种情况下调用canGoBack
and getActive()
on this.nav
工作正常,因为其他页面已使用推送this.nav.push
in app.component
.
但是,如果从选项卡中的某个页面推送页面(我们称其为page1
),即通过调用this.navCtrl.push()
in page1
, then this.nav.canGoBack()
in app.components
仍然解析为 false,因为推送是使用page1's
this.navCtrl.push()
不是应用程序组件的this.nav.push()
.
怎样才能检测到里面app.components
是否从选项卡中的任何页面推送页面?
platform.registerBackButtonAction(() => {
if(this.nav.canGoBack()){
this.nav.pop();
}else{
if(this.alert){
this.alert.dismiss();
this.alert =null;
}else{
this.showAlert();
}
}
});
});
}
None
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)