首页 > 解决方案 > Angular 8 - 使用路由器服务路由到初始 url 得到一个冗余的“/”

问题描述

在我的 app-routing.module 中,他有以下路线:

const routes: Routes = [
  { path: 'first-component', component: FirstComponent },
  { path: 'second-component', component: SecondComponent },
  { path: '', loadChildren: () => import('./home-page/home-page.module').then(m => m.HomePageModule)},
]

初始 url 是应用程序的主页。

当我使用 -

 this.router.navigate([''],{queryParams: {inst: this.institutionCode}});

网址如下所示:

主机:端口/INITIAL_URL/?inst=X

我可以不同地定义主页路由,这样我就不会在查询参数之前得到额外的“/”吗?

标签: angularroutes

解决方案


推荐阅读