在html中的设置
<div class="product">
<p>
这里是商品信息组件
</p>
<a>{{productId}}</a><br>
<!--这个位置一定是'./',这样才能找到子路由,而'/'则找到的是跟路由-->
<a routerLink='./'>商品信息</a>
<a [routerLink]="['./seller',99]">销售员信息</a>
<router-outlet></router-outlet>
</div>
在app.routing.module.ts中的设置
{path : 'product/:id', component: ProductComponent, children: [
{path: '', component: ProductDescComponent},
{path: 'seller/:id', component: SellerInfoComponent },
],
}