【问题标题】:Angular 9 Unwanted redirect after page reload页面重新加载后Angular 9不需要的重定向
【发布时间】:2020-09-15 10:44:35
【问题描述】:

我无法理解 Angular 路由器的行为。目前,路由模块如下所示:

const routes: Routes = [
{
    path: '',
    component: ManageCompetitionComponent,
    children: [
        {
            path: ':eventID',
            component: EventProfileComponent,
        },
    ],
}];

当我打开http://localhost:4200/admin/competition 并单击导航到http://localhost:4200/admin/competition/1234 的链接时,它工作正常,EventProfileComponent 显示为ManageCompetitionComponent 的一部分(包含一个路由器插座)。

但是当我现在从 浏览器 调用时(例如刷新/F5):

http://localhost:4200/admin/competition         -> works fine
http://localhost:4200/admin/competition/1234    -> redirects to /admin/competition

那么我该如何防止这种重定向呢?

【问题讨论】:

    标签: angular angular-routing angular-router


    【解决方案1】:

    试试这个,

    const routes: Routes = [
    {
        path: '',
        component: ManageCompetitionComponent,
       
    }, 
    {
        path: ':eventID',
        component: EventProfileComponent,
    }];
    

    【讨论】:

      猜你喜欢
      • 2021-05-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多