【发布时间】:2016-05-27 08:03:14
【问题描述】:
我有主应用程序组件,在管理组件下我想添加子路由,例如 /admin/users、/admin/subscribers
@Component({
selector: 'my-app',
template: `<router-outlet></router-outlet>`
directives: [ROUTER_DIRECTIVES]
})
@Routes[
new Route({
path: '/admin/...',
//name: 'Admin',
component: AdminPage
})
]
这是管理组件的配置
@Component({
selector: 'admin-Page',
templateUrl: applicationPath + '/adminPage.html',
directives: [ROUTER_DIRECTIVES]
})
@Routes([
new Route({
path: '/users',
component: UsersPage,
// name: 'Users',
// useAsDefault:true
}),
new Route({
path: '/subscribers',
component: SubscribersPage,
// name: 'Subscribers'
})
]
...但问题是应用程序无法识别路由 /管理员/用户。新路由器不支持此行为 还有吗?只是语法不同吗?
【问题讨论】:
-
错误消息说这是
AppComponentinline template:2:12 中的错误,但您的代码不包含AppComponent或模板。请添加AppComponent的代码。 -
我发现错误I subcomponent used the deprecated router,新路由器是否支持非最终路由?像 '/admin/...' 因为现在我收到了一个不匹配的路由错误?
-
/...在新路由器中不再是必需的。对于该错误,请确保您在@Routes([...])中的路线已排序,以便最不具体的路线排在最后。 -
好的,但是我在多个组件之间拆分了路线,这意味着使用新的@Routes 我应该将所有路线集中到一个地方?
-
我会为此添加一个新问题