我是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)中。 –