我剛開始學習的角度路由器和我無法使用命名出口,請看看下面的代碼錯誤:無法匹配任何路線。 URL段:「家」
const routes: Routes = [{
path: "about",
component : AboutComponent,
children : [{
path : "contact",
component: ContactComponent }, {
path : "message",
component: MessageComponent }, {
path : "",
component: ContactComponent },
]},
{
path: "home",
component : HomeComponent
// outlet : "main" When I add this, it is not working
},{
path: "",
component : HomeComponent,
outlet : "main"
}];
app.component.html
------------------
<h1>The Header</h1>
<a routerLink="home">Home</a>
<a routerLink="about">About</a>
<router-outlet></router-outlet>
<router-outlet name="main"></router-outlet>
<h1>The footer</h1>
上面的代碼工作正常,但當我加出口path:'home'
,它說 Error: Cannot match any routes. URL Segment: 'home'
。
如果你剛開始學習路由,你可能有興趣在我的課程:「角路由」:https://app.pluralsight.com/library/courses/角度路由/目錄它涵蓋了許多不同類型的路由。您可以免費註冊一週。 – DeborahK