當我點擊“投資組合”超鏈接時。

投資組合頁面不顯示(見下文)

我不完全了解路由系統。
這是我的檔案的結構

在檔案夾中 ->身份
身份.component.html
<router-outlet></router-outlet>
singin.component.html
<div
style="background-color: green; width: 100%; height: 98px;"
></div>
<h1 style="text-align: center">Singin page</h1>
<div style="text-align: center">
<a href="portfolio">Portfolio</a>
</div>
在檔案夾 -> * Admin
管理組件.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>Portfolio page</h1>
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
<router-outlet> </router-outlet>
我在Stackblitz上與您分享我的代碼
非常感謝您的幫助。
uj5u.com熱心網友回復:
使用routerLink. 請參閱更新的StackBlitz。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/367295.html
標籤:有角的
上一篇:為什么@angular/core/core沒有匯出成員'??FactoryDe??claration'。使用angularcdk虛擬滾動條時拋出的錯誤
