Angular routing error: should only include this file once

Angular routing error: should only include this file once

我在玩tutorial Tour of Heroes found here。一切正常,看起来很好。但是,在我添加从根页面到仪表板和英雄详细信息的路由后,我在控制台中收到以下错误:

Unexpected condition on http://localhost:3000/dashboard: should only include this file once

在我点击 link 到仪表板后出现错误。 该消息是从该行代码中抛出的:

expect(!loadTimeData, 'should only include this file once');

VM1812:155 中。 JS版本为V8 5.6.326.50。我使用的 Angular 版本是 4.0.0,如 package.json:

中所声明
"dependencies": {
  "@angular/common": "~4.0.0",
  "@angular/compiler": "~4.0.0",
  "@angular/core": "~4.0.0",
  ...
}

dashboard.component.ts

import { Component, OnInit  } from '@angular/core';

import { Hero } from '../heroes/hero';
import { HeroService } from '../model/hero.service';

@Component ({
  selector: 'my-dashboard',
  templateUrl: './html/dashboard.component.html',
  styleUrls: ['./css/app.css'],
})

export class DashboardComponent implements OnInit {

  heroes: Hero[] = [];

  constructor(private heroService: HeroService) { }

  ngOnInit(): void {
    this.heroService.getHeroes()
      .then(heroes => this.heroes = heroes.slice(1, 5));
  }
}

/dashboard 页面在 app.component 模板中 link 编辑,如下所示:

<nav>
  <a routerLink="/heroes">Heroes</a><!--another page, also problematic-->
  <a routerLink="/dashboard">Dashboard</a>
</nav>
<router-outlet></router-outlet>

路由定义是在这样的模块中定义的:

@NgModule({
  imports: [ RouterModule.forRoot(
    [
      { path: '', redirectTo: '/dashboard', pathMatch: 'full' },
      { path: 'dashboard',  component: DashboardComponent },
    ]
  ) ],
  //...
})

有人知道这个错误是什么意思,为什么会弹出?

我检查了每个浏览器,似乎它只适用于 Yandex 浏览器。在我看来,该错误需要发送给 Yandex 支持团队。但是,它不会影响最终用户体验或任何功能。我们现在可以安全地忽略它。

PS - angular 应用程序无法在旧版 safari (5.1.7) 上运行,请使用仅在 MacOS 或任何其他现代浏览器上可用的最新版本 (9-10) .