我尝试使用硬件后退按钮从特定页面(HometabsPage )退出应用程序。我使用下面的代码:
var lastTimeBackPress = 0;
var timePeriodToExit = 2000;
platform.registerBackButtonAction(() => {
let view = this.nav.getActive();
if (view.component.name == 'SignInPage' ) {
if (new Date().getTime() - lastTimeBackPress < timePeriodToExit) {
platform.exitApp(); //Exit from app
} else {
this.common.presentToast("Press back again to exit App?", "bottom");
lastTimeBackPress = new Date().getTime();
}
} else {
this.nav.pop({});
}
});
在我的应用程序中有两个部分SignIn和Hometabs。上面的代码在登录页面上工作正常。
if (view.component.name == 'SignInPage' )
但是在所有页面中显示吐司消息之后,我尝试使用“ HometabsPage ”而不是“ SignInPage ”。
请帮我。