Angular 4 带有嵌套组件的路由

Angular 4 Routing with nested components

我想要这样的路由: 根 root/childA root/childB root/childC

根目录是一个仪表板组件,它具有指向子项的链接,但单击它们后,仪表板不会保留,它只会被子项替换。这将是一个具有后退按钮和面包屑的移动友好型 UI。 实现此目标的最佳方法是什么?

这很简单。像这样定义你的路径:

{ path: 'root', children: (<Routes> [
  { path: '', component: RootComponent, },
  { path: 'childA', component: ChildAComponent, },
  { path: 'childB', component: ChildBComponent, },
  { path: 'childC', component: ChildCComponent, },
])}

查看 angular 教程以获取有关面包屑的信息。对于移动设备友好,请查看响应式开发(即通过 bootstrap 或其他方式)。

祝你好运。