我有一个导航栏和我的 app.component.html :
<div id="navigation">
<ul>
<li class="active"><a routerLink="accueil">Accueil</a></li>
<li><a routerLink="apropos" >A propos de nous</a> </li>
<li class="has-sub" ><a routerLink="" >Payer</a>
<ul>
<li><a routerLink="payer/nat" >Vol national</a></li>
<li><a routerLink="payer/int" >Vol international</a></li>
</ul>
</li>
<li><a routerLink="temoin" >Temoignages</a>
<li><a routerLink="contact">Contact</a> </li>
</ul>
</div>
<router-outlet></router-outlet>
我还有我的应用路由文件:
const routes: Routes = [
{ path: 'accueil', component: WelcomeComponent,
children: [
{ path: '', component: WelcomeComponent },
{ path: 'apropos', component: IdentiteComponent },
{ path: 'payer', component: VoyagenatComponent },
{ path: 'payer/nat', component: VoyagenatComponent },
{ path: 'payer/int', component: VoyageinternatComponent },
{ path: 'contact', component: ContactComponent },
{ path: 'temoin', component: TemoinComponent },
]
},
{ path: '',
redirectTo: '/accueil',
pathMatch: 'full'
},
{ path: '**', component: PagenotfoundComponent }
];
我想要这种行为
但是当我点击“Accueil”或“Payer”或任何其他链接时,我将重定向到 http://localhost:4200/accueil
我该如何解决这个问题?我如何使用子路径示例:VoyageinternatComponent ===> http://localhost:4200/payer/int