我试图从儿童路线导航到回家路线但没有任何反应。
即目前的路线是/projects
this.router.navigate(['/'])
和routerLink="/"
都不起作用。
我的routerConfig
看起来像这样
const routes: Routes = [
{
path: '',
component: HomeComponent
},
{
path: '/projects',
component: ProjectsComponent
}
]
我该怎么做呢?
尝试将redirectTo
路由添加到您的路由配置:
const routes: Routes = [
{ path: '', redirectTo: 'home', pathMatch: 'full' },
{ path: 'home', component: HomeComponent },
{ path: 'projects', component: ProjectsComponent }
];