带有查询参数和附加路由的Angular路由。

问题描述 投票:0回答:1

我正在使用Angular 9应用程序。

我有一个路由文件,其中有以下代码。

{ path: 'a/:id', component: AComponent },
{ path: 'a/b', component: BComponent },
{ path: 'a/c', component: CComponent }

我想拥有同样的路由 'a' 带查询参数 id 以及附加路线(b& c)

当我试图导航到 'a/b''a/c'浏览器中的URL得到了更新,但是,实际上并没有导航到所需的路径。

有什么方法可以实现吗?

angular parameters routes query-parameters
1个回答
0
投票

路由的顺序是很重要的,因为Router在匹配路由时采用的是先匹配胜出的策略,所以比较特殊的路由应该放在不太特殊的路由上面。

在你的情况下。

{ path: 'a/b', component: BComponent },
{ path: 'a/c', component: CComponent },
{ path: 'a/:id', component: AComponent },
© www.soinside.com 2019 - 2024. All rights reserved.