angular - 导航子路由Angular
问题描述
我有 app-routing (for root)
{ path: 'login', component: LoginComponent },
{ path: 'swagger', component: SwaggerComponent },
{ path: '**', component: PageNotFoundComponent}
我创建了其他路由器插座(为孩子)
{ path: '',
component: LayoutComponent,
children: [
{
path: 'manufacturers',
component: ShowManufacturerComponent,
children: [
{
path: 'add',
component: AddComponent,
},
{
path: 'edit/:id',
component: EditComponent,
},
]
},
{ path: 'products', component: ShowProductComponent },
{ path: 'categories', component: ShowCategoryComponent },
]
}
和布局组件
<header></header>
<sidebar></sidebar>
<router-outlet></router-outlet>
<footer></footer>
现在这是路由器树
AppComp
--PageNotFoundComp
--SwaggerComp
--LoginComp
--LayoutComp
--ShowManufacturerComp
--AddComp
--EditComp
--ShowCategoriesComp
....
当我使用
<a routerLink="add">Add</a>
或者
<a routerLink="/manufacturers/add">Add</a>
只有 ShowManufacturersComp 显示。如何解决这个问题,tks
解决方案
ShowManufacturerComponent
配置为具有子路由。
在组件模板中,您需要包含一个router-outlet
.
推荐阅读
- search - Microsoft 搜索中以国家/地区为目标的书签不起作用
- javascript - 运行 JSON.parse() 时如何解决意外的 json 错误结束
- python - 操作系统错误:在我的 python 项目中安装 django 时 [WinError 123]
- python - 为什么我必须双击才能真正做某事?
- reactjs - 无法在使用 WebdriverIO 的反应应用程序中获取每个文件覆盖率
- php - Elementor 自定义小部件的图标不显示
- ssh - 缺少 cloud9 中的 .ssh 文件
- jquery - jquery获取父级索引
- omnet++ - 有什么方法可以跟踪 OMNET++ 中的执行情况
- javascript - 如何避免使用递归函数