路由URL在角度7中不像以前那样工作

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

路由模块路径配置

{ path: 'invite/:token', component: PreAuthComponent },

以前我们用过

localhost:4200/#/invite/?key=12345

但是在更新到角度7之后它没有同时采取/?结合而不能导航。如何使用上述相同配置实现此目的。

目前使用不同配置的工作URL

{ path: 'invite/:token', component: PreAuthComponent }

localhost:4200/#/invite/12345

要么

{ path: 'invite', component: PreAuthComponent }

localhost:4200/#/invite?key=12345
angular angular-ui-router angular2-routing angular7 query-parameters
1个回答
2
投票

根据Locationstrategy,您可以通过在LocationStrategy方法中设置useHash: true来更新RouterModule.forRoot(),如下所示。

RouterModule.forRoot(routes, { useHash: true })  // .../#/crisis-center/

顺便说一下,路径参数(“/ feature /:id”)和查询参数(“feature?key = value”)在Angular中是非常不同的。 route参数可用于路由和组件处理。通常,查询参数仅在NgComponent中处理。

© www.soinside.com 2019 - 2024. All rights reserved.