gpt4 book ai didi

javascript - Angular 路由错误 : should only include this file once

转载 作者:太空狗 更新时间:2023-10-29 18:13:37 25 4
gpt4 key购买 nike

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

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

单击仪表板链接后出现错误。该消息从该行代码中抛出:

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 模板中,如下所示:

<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)。

关于javascript - Angular 路由错误 : should only include this file once,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43027804/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com