relativeLinkResolution 在 Angular 15 中不起作用,但它曾经在 11 中起作用

问题描述 投票:0回答:0

对于我从 Angular 11.2.2 迁移到 15.2.8 的项目。

在编译时抛出这个错误

Argument of type '{ useHash: true; relativeLinkResolution: string; }' is not assignable to parameter of type 'ExtraOptions'. 
Object literal may only specify known properties, and 'relativeLinkResolution' does not exist 
in type 'ExtraOptions'. 

44 relativeLinkResolution: 'legacy'

我的代码

@NgModule({
  imports: [
    RouterModule.forRoot(routes, {
    useHash: true,
    relativeLinkResolution: 'legacy' <-- this is shown as error even by VS
})
  ],
  exports: [RouterModule]
})
export class AppRoutingModule {}

VS显示的错误是

Argument of type '{ useHash: true; relativeLinkResolution: string; }' is not assignable to parameter of type 'ExtraOptions'.
  Object literal may only specify known properties, and 'relativeLinkResolution' does not exist in type 'ExtraOptions'.ts(2345)

它在上一个版本之前工作正常。我已经导航到 ExtraOptions 并且无法在任何地方找到这些属性。这些属性是否从 Angular 15 中丢弃,如果是,那么它的替代方案是什么。

它也没有解析 Routes 元素的 loadChildren 属性

{
    path: "",
    component: AdminLayoutComponent,
    children: [
      {
        path: "",
        loadChildren:
          "./layouts/admin-layout/admin-layout.module#AdminLayoutModule"
      }
    ]
  }

路径应该像这样解析 => [localhost:4200/#/dashboard]

routes relative-path legacy angular15
© www.soinside.com 2019 - 2024. All rights reserved.