请告诉我如何从该组件开始http://localhost:4200/(letone:一个(使用链接到另一个组件,例如这里http://localhost:4200/(第二册:两册(
我试着像这个一样做
<button [routerLink]="['../', { outlets: { 'lettwo' : 'two' } }]">Button Two</button>
但不起作用
在使用不同网点的特定场景中,它应该是:
app.component.html
<router-outlet name="letone"></router-outlet>
<router-outlet name="lettwo"></router-outlet>
应用程序路由器模块.ts
const routes: Routes = [
{
path: '',
children: [
{ path: 'one', component: PageOneComponent, outlet: 'letone' },
{ path: 'two', component: PageTwoComponent, outlet: 'lettwo' },
],
},
];
第一页.component.html
<p>Page one - 1</p>
<button [routerLink]="['/', { outlets: { letone: null, lettwo : 'two' } }]">to Two</button>
第二页.component.html
<p>Page two - 2</p>
<button [routerLink]="['/', { outlets: { letone : 'one', lettwo: null } }]">to One</button>
文件:https://angular.io/api/router/Router#createUrlTree
示例:https://stackblitz.com/edit/angular-ivy-be5nd8