angular - Angular 6:路由路径附加在查询字符串之后
问题描述
我的情况就像我的应用程序正在 iframe 中加载。所以首先它会从 URL 中读取查询字符串并根据值重定向应用程序。但每次这样做时,它都会将路由路径附加到查询字符串的末尾。我的代码。
应用程序组件
ngOnInit(){
if (conditionmatch) {
this.router.navigate(['template-not-found'])
}
}
路由模块
{ path: 'template-not-found', component: TemplateNotFoundComponent },
例如,我的初始条件是https://localhost:44351/id=152&projId=130
所以在条件匹配之后它会转到该页面,但它会在末尾附加路由路径。https://localhost:44351/id=152&projId=130#/template-not-found
我应该如何处理它以便它出现在查询字符串之前?
解决方案
要相对于根导航,您必须在第一段路径之前放置一个斜杠。
所以试试
ngOnInit(){
if (conditionmatch) {
this.router.navigate(['/template-not-found'])
}
}
推荐阅读
- android - 访问 ActivityResult 上的公共下载文件 Android 28 Samsung Galaxy S9+ (Verizon)
- java - 从 JNI 运行时 Java ShutdownHook 无法加入主线程
- javascript - 动画跑完后可以倒放吗?
- c# - 无法在 Visual Studio 2017 中引用 Windows IoT
- javascript - 给下拉链接一个功能
- neo4j - Neo4j Cypher 关系语法
- sql - 总和列,但对于每一行
- facebook - 带有 Facebook 提供商的 Azure B2C
- javascript - 刷新时更改背景颜色和文本颜色
- firebase - 带有自定义重定向域的 Firebase 身份验证不支持 TLS