ban*_*'14 3 javascript routing angular-routing angular
我正在玩这里的英雄之旅教程.一切都运行,看起来很好.但是,在我从根页面添加路由到仪表板和英雄的详细信息后,我在控制台中收到以下错误:
Unexpected condition on http://localhost:3000/dashboard: should only include this file once
Run Code Online (Sandbox Code Playgroud)
点击指向仪表板的链接后会看到错误.从该行代码抛出消息:
expect(!loadTimeData, 'should only include this file once');
Run Code Online (Sandbox Code Playgroud)
在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",
...
}
Run Code Online (Sandbox Code Playgroud)
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));
}
}
Run Code Online (Sandbox Code Playgroud)
该/dashboard页面在app.component模板中链接,如下所示:
<nav>
<a routerLink="/heroes">Heroes</a><!--another page, also problematic-->
<a routerLink="/dashboard">Dashboard</a>
</nav>
<router-outlet></router-outlet>
Run Code Online (Sandbox Code Playgroud)
和路由定义在以下模块中定义:
@NgModule({
imports: [ RouterModule.forRoot(
[
{ path: '', redirectTo: '/dashboard', pathMatch: 'full' },
{ path: 'dashboard', component: DashboardComponent },
]
) ],
//...
})
Run Code Online (Sandbox Code Playgroud)
任何人都知道这个错误意味着什么以及它弹出的原因?
我检查过每个浏览器,似乎只适用于Yandex浏览器.从我的角度来看,需要将该bug发送给Yandex支持团队.但是,它不会影响最终用户体验或任何功能.我们现在可以放心地忽略它.
PS - 角度应用程序不适用于旧的Safari(5.1.7),使用最新的(9-10),仅适用于MacOS或任何其他现代浏览器.
| 归档时间: |
|
| 查看次数: |
1071 次 |
| 最近记录: |