當我點擊“點擊這里”

然后,我點擊“投資組合”

通常必須出現標題“投資組合頁面”。在這里,我什么也沒看到。

我認為是路由的問題,但我不明白......
具體來說,我不知道問題出在哪里,如果您有解決方案我真的很感興趣。
以下是我的檔案的資訊結構

app-routing.module
const routes: Routes = [
{
path: '',
pathMatch: 'full',
redirectTo: 'identity',
},
{
path: 'admin',
component: AdminComponent,
children: [
{
path: 'portfolio',
component: PortfolioComponent,
},
],
},
{
path: 'identity',
component: IdentityComponent,
children: [
{
path: '',
pathMatch: 'full',
redirectTo: 'singin',
},
{
path: 'singin',
component: SinginComponent,
},
],
},
];
管理組件.html
<div ></div>
<input type="checkbox" id="openSidebarMenu" />
<label for="openSidebarMenu" >
<div ></div>
<div ></div>
<div ></div>
</label>
<div id="sidebarMenu">
<ul >
<li>
<a routerLink="portfolio"> <i ></i>Portfolio </a>
</li>
</ul>
</div>
投資組合.component.html
<h1 style="text-align: center">Portfolio page</h1>
代碼在這里
uj5u.com熱心網友回復:
{
path: 'admin',
component: AdminComponent,
children: [
{
path: 'portfolio',
component: PortfolioComponent,
},
],
},
這段配置說投資組合組件將作為 AdminComponent 的子組件呈現 -> 即在 AdminComponent 的模板中。您應該添加<router-outlet>到 AdminComponent,以便路由器知道在哪里呈現這個孩子
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/367293.html
標籤:有角的
上一篇:如何從控制臺避免此錯誤?
下一篇:為什么@angular/core/core沒有匯出成員'??FactoryDe??claration'。使用angularcdk虛擬滾動條時拋出的錯誤
