我对 Angular 4 路由器和组件有一些问题。我正在尝试做的事情。我有一个视图(超级用户),其中包含 2 个出口(侧边菜单和内容)。
在路由器中,我有 2 个孩子(侧边菜单和内容)的超级用户,它有自己的路由器,但我得到无法匹配任何路由。URL 段:http://localhost:4200/superuser/contexts uri上的“超级用户/上下文”。来源如下。
应用路由器
export const routes: Routes = [
{
path: "home",
component: HomeComponent
},
{
path: "superuser",
component: SuperuserComponent,
children:[
{
path: "",
component: SideMenuComponent,
outlet: 'superuser-sidemenu'
},
{
path: "contexts",
component: ContextsComponent,
outlet: 'superuser-content'
}
]
},
{
path: "",
redirectTo: "/home",
pathMatch: "full"
}
]
超级用户组件.html
<div class="py-5 public-area-body-background">
<div class="container-fluid">
<div class="row">
<div class="col-md-2">
<div id="superuser-sidemenu">
<router-outlet name="superuser-sidemenu"></router-outlet>
</div>
</div>
<div class="col-md-10">
<div id="superuser-content">
<router-outlet name="superuser-content"></router-outlet>
</div>
</div>
</div>
</div>
</div>
SideMenuComponent.html
<div class="card text-white p-5 bg-light shadow sidemenu">
<div class="card-body sidemenu">
<h4 class="mb-4 text-dark" >Main Menu</h4>
<div class="input-group">
<select class="custom-select" id="inputGroupSelect04">
<option selected>Context...</option>
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
</select>
</div>
</div>
</div>
ContextsComponent.html
<div class="card text-white p-5 bg-light shadow">
<div class="card-body">
<p>Content here</p>
</div>
谢谢!