[英]how to use router-outlet in a proper way
嗨,我有以下代碼:app.routing.module
const routes: Routes = [
{path: '', redirectTo:'/head', pathMatch:'full'},
{path:'head',component: HeadComponent},
{path:'main',component: MainComponent},
];
頭上有:
<router-outlet></router-outlet>
它應該自動導航到main,但不是。 我需要做空所有組件的根.regards
頭中的路由器出口只會渲染頭子,而您根本沒有。
您的路線已設置為自動在應用程序組件的路由器出口中渲染頭部。 Head沒有孩子,因此不會渲染main。 您需要在head的子級中添加main。
const routes: Routes = [
{path: '', redirectTo:'/head', pathMatch:'full'},
{
path:'head',
component: HeadComponent,
children: [
{path:'',component: MainComponent}
]
}
];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.