【问题标题】:Angular auxiliary routes works locally but not when deployedAngular 辅助路由在本地有效,但在部署时无效
【发布时间】:2020-12-29 16:09:06
【问题描述】:

我在直接访问辅助路由时遇到问题。当我在本地访问 /home/(post:12) 时,一切正常。但是当我在将应用程序部署到 github 页面时尝试这样做时,会出现 Wild 404。

基本上辅助路由是加载弹窗模式。

<router-outlet name="post"></router-outlet>

这里是路由器模块:

RouterModule.forRoot([
      {
        path: 'home',
        component: ShellComponent,
        children: [
          {
            path: ':postId',
            component: PostEntryComponent,
            outlet: 'post'
          },
          {
            path: '',
            redirectTo: 'home',
            pathMatch: 'full'
          }
        ]
      },
      {path: '**', redirectTo: 'home'}
    ])

我想让它像在本地服务器上一样工作。有什么想法吗?

【问题讨论】:

    标签: angular routes angular-routing angular-auxiliary-routes


    【解决方案1】:

    会有帮助吗?

    // Excerpt app-routing.module.ts
    
    @NgModule({
      imports: [
        RouterModule.forRoot(routes, {
          useHash: true,
        }),
      ],
      exports: [RouterModule],
    })
    

    【讨论】:

      猜你喜欢
      • 2019-07-12
      • 2019-11-14
      • 1970-01-01
      • 2020-10-16
      • 2018-10-17
      • 2021-11-19
      • 2018-08-16
      • 1970-01-01
      • 2017-08-31
      相关资源
      最近更新 更多