angular - Angular 路由器阻止对服务器的调用
问题描述
这是我的路由器代码:
const routes: Routes = [
{ path: '', component: IndexComponent},
{ path: 'microservice/:id', component: MicroserviceComponent}
];
我正在尝试通过加载这样的 URL(获取请求)从服务器加载端点
window.open("localhost:8080/api/login", "_self");
但是,如果我在主页(路径''
)中执行此操作,它会到达服务器,我可以从服务器端看到它。如果我在microservice/bluh
页面中运行此代码,则会显示主页并且不会点击登录端点。
阻止呼叫到服务器的路由是否有问题?
解决方案
将 pathMatch: 'full' 添加到您的主要组件:
const routes: Routes = [
{ path: '', component: IndexComponent,pathMatch: 'full' },
{ path: 'microservice/:id', component: MicroserviceComponent}
];
推荐阅读
- performance - 在 Aurora-mysql 中插入大量数据时的性能问题
- java - Stack implementation using LinkedList in Java
- python - 列表中第四大元素的 Python 程序?
- javascript - 为什么在控制台中声明变量会产生未定义的输出?
- php - Laravel 刀片将数据传回包含的组件
- tensorflow - 健身房(Open AI)环境状态改变形状
- maven - 将 pom 版本号添加到 Artifactory 存储库路径
- react-hooks - 问题 React Hooks 项目中的反应草稿所见即所得包无法集成
- reactjs - 反应列表重复项
- mongodb - MongoDb - 触发相同查询后的内存读取与磁盘读取