这是不可能的。 Angular 需要知道应该使用哪个
router-outlet
。一种方法是使用 child-routes
。那么主组件中就只有自己的 router-outlet
,每个子组件也有一个 router-outlet
。
const routes: Routes = [
{
path: 'first-component',
component: FirstComponent, // this is the component with the <router-outlet> in the template
children: [
{
path: 'child-a', // child route path
component: ChildAComponent, // child route component that the router renders
},
{
path: 'child-b',
component: ChildBComponent, // another child route component that the router renders
},
],
},
];
孩子可以生孩子,两个。所以你的路线看起来不同,而且没有
(sidebar:cart-page)
。