router.navigate 在 Angular 中不工作

router.navigate is not working in Angular

下面是我的重定向方法,它不起作用

    goToProdPage() {
       this.router.navigate([this.quoteId,'/cpq']);
       window.location.reload();
    }

但如果我将其更改为

goToProdPage() {
     this.router.navigate(['./'+this.quoteId+'/cpq']);
     window.location.reload();
}

然后它工作正常。但现在我无法从其他组件中的 activatedRoute 获取 url 参数(即 quoteId)。

下面是app.module.ts

中的路由代码
const appRouter :Routes = [
   {path:'login', component: loginPage},
   {path:':quoteId/cpq', component: cpqPage},
   {path:'', redirectTo:'/login', pathMatch:'full'},
]

您不需要 window.location.reload(); 它将跳过缓存并重新加载同一页面,将其更改为

goToProdPage() {
    this.router.navigate([this.quoteId, 'cpq']);   
}