我认为您需要考虑的是您真的想要子路线还是只是同一页面或每个级别?另一个示例最终将渲染两个组件......这可能是您想要的,但如果不是,那么您可能会拼写出每个组件。
{ path: 'matches/results/', component: ResultsComponent, },
{ path: 'matches/results/:page/', component: PageComponent, },
{ path: 'matches/results/:page/:team/', component: TeamComponent, },
{ path: 'matches/results/:page/:team/:season', component: PageComponent, },
另请注意,您在路径中使用的名称是您需要在参数选择器中使用的名称:
params['page']
params['team']
params['season']
示例代码
this.route.params.subscribe((params) => {
this.teamService.getTeam(params['team']).subscribe((team) => {
this.team = team;
});
});