[英]Routing URL is not working as previous in angular 7
Routing module Path configuration路由模块路径配置
{ path: 'invite/:token', component: PreAuthComponent },
Previously we were using以前我们使用
localhost:4200/#/invite/?key=12345
but after update to angular 7 it's not taking both /?但是在更新到 angular 7 之后,它并没有同时使用 /? combine and not able to navigate.
结合而无法导航。 How to achieve this with same configuration mentioned above.
如何使用上述相同的配置来实现这一点。
currently working URL's with different configuration当前使用不同配置的 URL
{ path: 'invite/:token', component: PreAuthComponent }
localhost:4200/#/invite/12345
or或者
{ path: 'invite', component: PreAuthComponent }
localhost:4200/#/invite?key=12345
According to Locationstrategy , you may update the LocationStrategy
by set useHash: true
in RouterModule.forRoot()
method as following.根据Locationstrategy ,您可以通过在
RouterModule.forRoot()
方法中设置useHash: true
来更新LocationStrategy
,如下所示。
RouterModule.forRoot(routes, { useHash: true }) // .../#/crisis-center/
By the way, the route parameter ("/feature/:id") and query parameter ("feature?key=value") is very different in Angular.顺便说一下,Angular 中的路由参数(“/feature/:id”)和查询参数(“feature?key=value”)是非常不同的。 route parameter can be used for routing and processed by component.
route 参数可用于路由和组件处理。 Usually, query parameter is only processed in NgComponent.
通常,查询参数只在 NgComponent 中处理。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.