【问题标题】:Redirecting file-URL to angular component将文件 URL 重定向到 Angular 组件
【发布时间】:2018-07-26 08:01:28
【问题描述】:

您好,我想迁移 Angular 4 项目中的现有链接。 例如我的链接是“http://www.test.com/test/site.aspx”。

我尝试了我的路由器配置:

    path: 'test', 
    component: TestComponent,
    children: [{
      path: '',
      component: ContactComponent
    }]

        path: 'test/site.aspx', 
        component: ContactComponent

但这些都不起作用。 任何想法如何解决这个问题?

【问题讨论】:

  • 抛出了什么错误?
  • {path: '**', redirectTo: '/404'} - 最后路由到我的 404 页面
  • 交换路径,有优先级。
  • 两者都不起作用。即使交换也不会改变结果。

标签: angular router angular4-router


【解决方案1】:

如下所示使用redirectTo:

{ path: 'test/site.aspx', redirectTo: '/contact', pathMatch: 'full' }, { path: 'contact', component: ContactComponent},

【讨论】:

  • 我抛出“找不到站点”页面/但“/contact”正在工作......它似乎以某种方式试图获取文件
  • 您可以直接浏览联系组件吗?您用来直接访问联系人组件的 url 是什么?
猜你喜欢
  • 1970-01-01
  • 2023-03-19
  • 2017-07-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-10-08
  • 1970-01-01
相关资源
最近更新 更多