“无组件路由不能有命名出口集”

tof*_*ofu 6 angular2-routing angular

在我的 ng2 应用程序中,我有以下路线:

const modalRoutes: Routes = [{
    path: 'modal_1',
    component: SomeModalComponent,
    outlet: 'modal',
    children: [
        {
            path: 'step_one',
            component: OneSubmodalComponent,
            outlet: 'submodal'
        },
        {
            path: 'step_two',
            component: AnotherSubmodalComponent,
            outlet: 'submodal'
        },
        {
            path: '',
            redirectTo: 'step_one',
            outlet: 'submodal',
            pathMatch: 'full'
        }
    ]
}];
Run Code Online (Sandbox Code Playgroud)

我有一个用于主页内容的未命名的路由器出口,该路由描述了一个模式的路由,该模式被路由到一个命名的出口modal,并且本身包含一个命名的出口submodal

从 Angular 2.2.4 开始,这工作得很好,但更新到 2.3.0+ 后,我现在收到错误Invalid configuration of route 'modal_1/': a componentless route cannot have a named outlet set。我可以看到这是因为重定向路由没有定义组件,但它应该只是重定向到step_one已定义的组件。我这里的路由设计有问题吗?

tof*_*ofu 0

解决了问题——使用上面的路线,我会得到类似的路径 /main(modal:modal_1/(submodal:step_1)),现在似乎无法正常工作。简化现在的路径/main(modal:modal_1/step_1)可以让它正常工作。我的路线就变成了:

const modalRoutes: Routes = [{
    path: 'modal_1',
    component: SomeModalComponent,
    outlet: 'modal',
    children: [
        {
            path: 'step_one',
            component: OneSubmodalComponent
        },
        {
            path: 'step_two',
            component: AnotherSubmodalComponent
        },
        {
            path: '',
            redirectTo: 'step_one',
            pathMatch: 'full'
        }
    ]
}];
Run Code Online (Sandbox Code Playgroud)