首页 > 解决方案 > 如何从 Angular 路由中删除 URL 的重定向

问题描述

访问 mywebsite.com 时,我不希望它重定向到 mywebsite.com/home 我希望它留在 /

当我使用 Angular 路由时,我该怎么做?

我查看了 Angular Docs 并用 Google 搜索了它,但似乎找不到答案

标签: angular

解决方案


您可以在路由配置中添加HomeCompeont到根路径

[{
  {
    path: '',
    component: HomeComponent,
    pathMatch: 'full'
  },
  {
    path: 'home',
    component: HomeComponent
  }
  .........
}]


推荐阅读