typescript 更新到Angular版本15时出现路由错误

nbysray5  于 2022-11-18  发布在  TypeScript
关注(0)|答案(1)|浏览(203)

对象常值只能指定已知属性,而且'text'不存在于型别'Route'中。

源代码/应用程序/应用程序-路由.模块.ts

const routes: Routes = [
      { path: '', redirectTo: '/dashboard', pathMatch: 'full' },
      { path: 'detail/:id', component: HeroDetailComponent },
      { path: "dashboard", component: DashboardComponent, text: "Dashboard" },
      { path: "heroes", component: HeroesComponent, text: "Heroes" },
    ];

当我运行update命令进入Angular v15时,出现了这种情况:ng update @angular/core@15 @angular/cli@15 .

ep6jt1vc

ep6jt1vc1#

我修复后,看到这一点的突破性变化:https://angular.io/guide/update-to-version-15#the-title-property-is-required-on-activatedroutesnapshot
text更改为title似乎消除了错误。
源代码/应用程序/应用程序路由.模块.ts [旧版]

const routes: Routes = [
      { path: '', redirectTo: '/dashboard', pathMatch: 'full' },
      { path: 'detail/:id', component: HeroDetailComponent },
      { path: "dashboard", component: DashboardComponent, text: "Dashboard" },
      { path: "heroes", component: HeroesComponent, text: "Heroes" },
    ];

源代码/应用程序/应用程序路由.模块.ts [新]

const routes: Routes = [
      { path: '', redirectTo: '/dashboard', pathMatch: 'full' },
      { path: 'detail/:id', component: HeroDetailComponent },
      { path: "dashboard", component: DashboardComponent, title: "Dashboard" },
      { path: "heroes", component: HeroesComponent, title: "Heroes" },
    ];

相关问题