背景:
我有一个后退和继续按钮,可以在向导中遍历各个阶段及其子步骤。
问题:
我有以下路线:
{
path: 'test/stage/1',
component: WizardComponent,
children: [
{
path: 'step/1',
component: Stage1Step1Component,
},
{
path: 'step/2',
component: Stage1Step2Component,
}
]
},
{
path: 'test/stage/2',
component: WizardComponent,
children: [
{
path: 'step/1',
component: Stage2Step1Component,
},
{
path: 'step/2',
component: Stage2Step2Component,
}
]
},
问题是,我希望由各种url加载的组件是非常具体的组件,因此我想避免共享StepComponent,因为每条路由都在执行一项非常特殊的任务。
我必须说:
如果是第1阶段,加载x组步骤
但是
如果是阶段2,则加载y组步骤。
我遇到的问题是,当我进入stage/2/step/1时,它会再次加载WizardComponent,我想避免这种情况。
有什么好的吃法吗
test/stage/:stage
同时也有一些条件选择使用哪些孩子?
也许是这样的?
{
path: 'test/stage/:stage',
component: WizardComponent,
children: [
{
path: '1/step/1',
component: Stage1Step1Component,
},
{
path: '1/step/2',
component: Stage1Step2Component,
}
{
path: '2/step/1',
component: Stage2Step1Component,
},
{
path: '2/step/2',
component: Stage2Step2Component,
}
]
}
(以上不起作用)