我是angular2的新手。我正試圖瞭解如何在特定模板中使用多個<router-outlets>
。我已經去了很多QA,但無法解決我的錯誤。錯誤:無法匹配任何路線。網址段: - 角2
router.module.ts
const routes: Routes = [
{
path: '',
redirectTo: 'one',
pathMatch: 'full'
},
{
path: 'two',
component: ClassTwo, children: [
{
path: 'three',
component: ClassThree,
outlet: 'nameThree',
},
{
path: 'four',
component: ClassFour,
outlet: 'nameFour'
}
]
},];
component1.html
<h3>In One</h3>
<nav>
<a routerLink="/two" class="dash-item">...Go to Two...</a>
<a routerLink="/three" class="dash-item">... Go to THREE...</a>
<a routerLink="/four" class="dash-item">...Go to FOUR...</a>
</nav>
<router-outlet></router-outlet> // Successfully loaded component2.html
<router-outlet name="nameThree" ></router-outlet> // Error: Cannot match any routes. URL Segment: 'three'
<router-outlet name="nameFour" ></router-outlet> // Error: Cannot match any routes. URL Segment: 'three'
component2.html
<h3>In two</h3>
component3.html
<h3>In three</h3>
component4.html
<h3>In four</h3>
當我點擊...去兩個。 ..在兩個被打印。 但點擊其他兩個鏈接給我的錯誤不能匹配任何路由
路由器的出口是另一種RO和你有導航 –
以及如何處理它們,我應該給那個先生? @RomanC –
我認爲它在[router](https://angular.io/docs/ts/latest/guide/router.html)中。 –