【发布时间】:2017-01-07 11:12:23
【问题描述】:
我在 Stack Overflow 上发现了许多路由问题,但没有回答我的问题。用户登录后,用户被路由到具有子路由的父级:
{
path: '',
component: LoginComponent,
},
{
path: 'parent',
component: ParentComponent,
children: [
{
// without this routing does not work
path: '',
redirectTo: 'parent'
},
{
path: 'child',
component: ChildComponent,
},
]
},
//... more routes
我的问题是没有children中提到的以下内容:
path: '',
redirectTo: 'parent'
用户根本不会从登录页面路由到父路由。但这也与我的网址混淆,而不仅仅是
localhost:3000/parent 我得到localhost:3000/parent/parent。那仍然显示正确的组件。但是当用户导航到别处时,出现错误:
无法匹配任何路线:'something/something'
如何解决这个问题,谢谢?
【问题讨论】:
标签: angular