簡體   English   中英

離子角度 - 當我有多個嵌套路由時,路由無法正常工作

[英]Ionic-angular - Routing is not working properly when I have multiple nested routes

我有兩個頁面,項目和用戶。 在項目頁面內,我有子路線,添加/編輯/刪除。 在用戶頁面內,我有幾個子路由,添加/刪除。 這使得路由結構如下所示。

應用程序路由.module.ts

 {
    path: "users",
    loadChildren: "./users/users.module#UsersPageModule",

  },
  {
    path: "items",
    loadChildren: "./items/items.module#ItemsPageModule"
  }

users.module.ts

{
    path: "",
    component: UsersPage,
    children: [
      {
        path: "add",
        component: EditUserComponent
      },
      {
        path: "",
        component: UserListComponent,
        pathMatch: "full"
      }
    ]
  }

items.module.ts

{
    path: "",
    component: ItemsPage,
    children: [
      {
        path: "additem",
        component: ItemDetailsComponent
      },
      {
        path: "",
        component: ItemListComponent,
        pathMatch: "full"
      }
    ]
  }

問題:加載應用程序后,如果我在同一頁面內的路徑之間切換一切正常,但一旦我訪問另一個頁面並再次返回上一頁並嘗試導航它就不起作用。

例如。 首先我訪問/items 然后/items/add 再次/items/。 在這里一切正常。 當我訪問 /users 並再次 go 回到 /items 時,問題就開始了。 因此,此時項目頁面加載良好,與 /items 相關聯。 但如果我嘗試導航 /items/add. UI 上似乎沒有發生任何事情。

我打開了路由跟蹤,發現它顯示Router Event: NavigationEnd ,任何線索為什么會發生這種情況?

這是 github 示例項目鏈接: https://github.com/Dhananjay-JP/ionic-routing-issue.git

你能告訴我們你是如何在 html 文件中編寫導航鏈接的嗎?

它可以是這樣的。

 <a [routerLink]="['users']">users</a> <a [routerLink]="['items']">items</a>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM