我们正在将项目从路由器弃用到新的角度2路线。我在路由器中不能找到类似于usedefault的东西。基本上,当我加载页面时,我们希望网址更改为{{3而不是http://website_name/index
答案 0 :(得分:1)
<强> RC3 强>
您可以使用 redirectTo ,例如:
export const YourAppRoutes: RouterConfig = [
{
path: '',
redirectTo: '/index',
terminal: true
},
{
path: 'index',
component: YouMainComponent,
children: [
{ path: '', component: YouMainComponentList },
{ path: ':id', component: YouMainComponentDetail }
]
}
];
<强> RC4 强>
export const YourAppRoutes: RouterConfig = [
{
path: '',
redirectTo: 'index',
pathMatch: 'full'
},
{
path: 'index',
component: YouMainComponent,
children: [
{ path: '', component: YouMainComponentList },
{ path: ':id', component: YouMainComponentDetail }
]
}
];
供参考:https://angular.io/docs/ts/latest/guide/router.html#!#redirect