繁体   English   中英

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']);   
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM