Angular 如何从角度路由中删除URL重定向

Angular 如何从角度路由中删除URL重定向,angular,Angular,当访问mywebsite.com时,我不希望它重定向到mywebsite.com/home,我希望它停留在/ 当我使用角度布线时,如何做到这一点 我查看了Angular文档并在谷歌上搜索了一下,但似乎找不到答案转到你的app-routing.module.ts文件,在文件底部编辑此片段: { path: '', redirectTo: 'home', pathMatch: 'full' }, { path: 'home', component: HomeComponent } 您可以

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

当我使用角度布线时,如何做到这一点


我查看了Angular文档并在谷歌上搜索了一下,但似乎找不到答案

转到你的app-routing.module.ts文件,在文件底部编辑此片段:

{
 path: '',
 redirectTo: 'home',
 pathMatch: 'full'
},
{
 path: 'home',
 component: HomeComponent
}
您可以在路由配置中将HomeCompont添加到根路径

[{ { 路径:, 组件:HomeComponent, 路径匹配:“已满” }, { 路径:“家”, 组件:HomeComponent } .........
}]这是我的路径。当我转到localhost:4200`````{path:'home',component:HomeComponent},{path:'staff',component:StafflistComponent},{path:'players',component:PlayersComponent},{path:'profile',component:PlayersSearchComponent},{path:'parks',component:ParksComponent},{path:'community',component:CommunityComponent},{path:'creative',component:CreativeComponent},{path:,重定向到:'home',路径匹配:'full'},{path:'**',重定向到:'home',路径匹配:'full'}“``更详细一点。当我访问mywebsite.com时,我不希望在URL中显示/home。其他组件可以使用/home,但不能使用home。当我尝试在上面添加代码时,它删除了/home,但没有加载home组件,只加载页眉和页脚使用以下{路径:,重定向到:,路径匹配:'full',{path:'home',重定向到:,component:HomeComponent},{path:'staff',component:StafflistComponent},{path:'players',component:PlayersComponent},{path:'profile',component:PlayersSearchComponent},{path:'community',component:community},{path:'creative',component:CreativeComponent},{path:'**',重定向到:'home',pathMatch:'full'}使用此集合初始加载哪个组件