【问题标题】:After update angular version 8 to 11, app is not running将 Angular 版本 8 更新到 11 后,应用程序未运行
【发布时间】:2020-12-14 09:06:20
【问题描述】:

我有一个从 8 到 11 的 Angular 应用程序版本更新。此路由器在更新后无法工作。应用程序运行时显示空白页。编译和浏览器控制台没有错误。如何解决问题?

export const AppRoutes : Routes = [
{ path: 'login', component: LoginPageComponent }
{ path: '', component: MainComponent},
{ path: '', component: MainComponent, children: [
    { path: 'test-one', loadChildren: () => import('./TestOne/TestOne.module').then(m => m.TestOneModule)},
    { path: 'test-two', loadChildren: () => import('./TestTwo/TestTwo.module').then(m => m.TestTwoModule), canActivate: [AuthGuard], runGuardsAndResolvers: 'always'}
]},
{ path: ':pageslug', component : MainComponent },
{ path: '**', component : MainComponent }

];

【问题讨论】:

  • 您好,尝试按照这篇文章添加路由器调试 - 可以提供帮助。 stackoverflow.com/questions/62016858/…>
  • @VikramJhurry 我正在尝试这个,但它不起作用。同样的问题。

标签: router-outlet angular11


【解决方案1】:

Angular 11 中关于路由器的一些重大更改如下:

router: * RouterModule.forRoot 中选项的 initialNavigation 属性不再支持 legacy_disabled、legacy_enabled、true 或 false 作为有效值。 legacy_enabled(旧默认值)改为 enabledNonBlocking 不推荐将 enabled 作为 RouterModule.forRoot initialNavigation 选项的有效值。已引入 enabledBlocking 来替换它 路由器:preserveQueryParams 已被删除,请改用 queryParamsHandling=”preserve” router:如果您正在访问 queryParams、fragment 或 queryParamsHandling 的 RouterLink 值,您可能需要放宽输入以接受 undefined 和 null。 (#39151)

请看: https://medium.com/swlh/angular-11-in-depth-9a7372b4a600

【讨论】:

    猜你喜欢
    • 2021-08-05
    • 2020-06-05
    • 2021-09-10
    • 1970-01-01
    • 1970-01-01
    • 2020-12-28
    • 1970-01-01
    • 2021-08-23
    • 2022-01-22
    相关资源
    最近更新 更多