每次刷新页面时如何防止Ionic导航到第一页

时间:2018-08-27 10:09:46

标签: angular ionic3 deep-linking

我正在使用Ionic 3 + Angular并正在Deeplinks上工作。 我已经配置了以下路由:

IonicModule.forRoot(
      App,
      { locationStrategy: 'hash'  },
      {
        links: [
          {
            component: ReportPage,
            segment: "report/:locationId/:itemId"
          },
          {
            component: HomePage,
            segment: "home/:locationId/:itemId"
          },
       ]
     }
 )

如果我点击home/1/2,它将按预期重定向到主页。 如果我点击report/1/2,它将按预期重定向到报告页面。

但是当我按下home/1/2并控制刷新页面时,问题就来了,它使我导航到报告页面。

我尝试使用ionicPage段,但没有运气。

谢谢。

1 个答案:

答案 0 :(得分:1)

如果您可以在链接对象中设置名称,例如:

links: [

        {
          component: HomePage,
          segment: "home/:locationId/:itemId",
          name: 'home',
        },
         {
          component: ReportPage,
          name: 'report',
          segment: "report/:locationId/:itemId"
        },
     ]