Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Nativescript 当我使用快捷键返回手机时,如何在根目录中导航并关闭应用程序_Nativescript_Router_Back_Angular2 Nativescript - Fatal编程技术网

Nativescript 当我使用快捷键返回手机时,如何在根目录中导航并关闭应用程序

Nativescript 当我使用快捷键返回手机时,如何在根目录中导航并关闭应用程序,nativescript,router,back,angular2-nativescript,Nativescript,Router,Back,Angular2 Nativescript,我有这样的路线: const routes: Routes = [ { path: 'home', component: HomeComponent, canActivate: [AuthGuard], children: [ { path: 'fp', component: FirstPageComponent }, { path: 'images', component: ImageCom

我有这样的路线:

const routes: Routes = [
  {
    path: 'home',
    component: HomeComponent,
    canActivate: [AuthGuard],
    children: [
      {
        path: 'fp', component: FirstPageComponent
      },
      {
        path: 'images', component: ImageComponent
      },
      {
        path: 'image/:id', component: ImageComponentgetbyId
      },
      {
        path: 'settings', component: SettingsComponent
      }
    ]
  },
  { path: 'login', component: LoginFirstComponent },
  { path: '', redirectTo: '/home/fp', pathMatch: 'full' },
];
我在fp中导航,图像,图像/1,图像,图像/2,图像,图像/3,图像,设置,fp

当我单击手机上的快捷键后退按钮时,我会在所有路线、fp、设置、图像、图像/3、图像、图像/2、图像、图像/1、图像、fp、关闭应用程序中逐步导航

当我点击快捷键“后退”按钮时,我想在根目录中导航并关闭应用程序。如果我在image/1中,我希望在image中导航并关闭应用程序


请你问我如何实现这一点好吗?

你可以简单地使用
路由器出口
而不是
页面路由器出口
,这样硬件后退按钮将跳过所有路由器出口导航,直接返回页面路由出口中的路由(或退出应用程序)在HomeComponent中我使用
,在AppComponent中我在module.ts
@NgModule中使用
({bootstrap:[AppComponent],
当我返回时,将在路径登录中导航并显示此错误:
System.err:StackTrace:System.err:Frame:function:“”,file:'file:///data/data/org.nativescript.SecuritySystemMobile/files/app/services/events.service.js,第33行,第46列
@NickIliev有什么想法吗?