2

我为我的应用程序设置了路由设置,带有 . 一切都很好,但我的一个观点加载了一个侧栏,我想使用不同的 . 当我尝试向组件添加其他路由时,我得到“不允许子路由用于“xxx”,在父路由路径上使用“...”。

有没有人添加了多层路由可以提供帮助?谢谢!

4

1 回答 1

4

父路由使用特殊...语法

//parent route
@RouteConfig([
    new Route({path: '/', component: DemoPage, name: 'Home'}), 
    new Route({path: '/demo/...', component: DemoPage, name: 'Demo'})
})

//child routes defined in separate route config
@RouteConfig([
    new Route({ path: '/spreadsheet', component: Spreadsheet, name: 'Spreadsheet' })
//etc   
])

我在这里有一个教程:http ://www.syntaxsuccess.com/viewarticle/routing-in-angular-2.0

您还可以在此处查看嵌套路由:

http://www.syntaxsuccess.com/angular-2-samples/#/demo/spreadsheet

左侧导航正在使用子路线。

于 2016-01-19T02:25:06.663 回答