koe*_*ech 8 typescript angular2-routing angular
我试图从儿童路线导航到回家路线但没有任何反应.
即目前的路线是 /projects
既不工作this.router.navigate(['/'])也不routerLink="/"工作.
我routerConfig看起来像这样
const routes: Routes = [
{
path: '',
component: HomeComponent
},
{
path: '/projects',
component: ProjectsComponent
}
]
Run Code Online (Sandbox Code Playgroud)
我该怎么做呢?
wun*_*uno 11
尝试添加redirectTo路由到您的路由配置:
const routes: Routes = [
{ path: '', redirectTo: 'home', pathMatch: 'full' },
{ path: 'home', component: HomeComponent },
{ path: 'projects', component: ProjectsComponent }
];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11016 次 |
| 最近记录: |