角度6:路由路径附加在查询字符串之后

我的情况就像我的应用程序正在iframe中加载。因此,首先它将从URL读取查询字符串,然后根据该值重定向应用。但是每次这样做都会将路由路径附加到查询字符串的末尾。我的代码。

app.component

 ngOnInit(){
 if (conditionmatch) {
    this.router.navigate(['template-not-found'])
  }
}

routing.module

{ path: 'template-not-found',component: TemplateNotFoundComponent },

例如,我的初始条件是https://localhost:44351/id=152&projId=130
因此,条件匹配后,它会转到该页面,但会在末尾附加路由路径。 https://localhost:44351/id=152&projId=130#/template-not-found

我应该如何处理它,使其出现在查询字符串之前?

lantianniu 回答:角度6:路由路径附加在查询字符串之后

要相对于根导航,必须在第一个段路径之前加一个斜杠。

所以尝试

ngOnInit(){
 if (conditionmatch) {
    this.router.navigate(['/template-not-found'])
  }
}
,

这似乎是您在使用相对路线。您要使用绝对路线,因此需要在路线前面加上斜杠,如下所示: pip3 install --pre matplotlib==3.2.0a1

本文链接:https://www.f2er.com/3165010.html

大家都在问