1
我使用同β7得到一個無限循環,這是Firefox的堆棧跟蹤:Angular2公測7無限循環
Error: Script terminated by timeout at:
DebugDomRenderer</[email protected]: //localhost:2067/node_modules/angular2/bundles/angular2.dev.js:7184:11
[email protected]_t:256:18
[email protected]_t:266:1
[email protected]_t:266:1
[email protected]_t:266:1
[email protected]_t:266:1
[email protected]_t:266:1
...
跳同β7一切正常之前,但如果我現在切換到beta6,我得到相同錯誤。所以我認爲這個問題甚至在以前就存在了。 正如你可以在AppComponent類中看到的,我正在處理2條路由:Main e NotFound。奇怪的是,如果我在瀏覽器中寫入不存在的URL(例如localhost:2056/asdad),NotFound頁面將正確顯示。
我的包:
"angular2": "2.0.0-beta.7",
"systemjs": "0.19.20",
"es6-promise": "^3.0.2",
"es6-shim": "^0.33.3",
"reflect-metadata": "0.1.2",
"rxjs": "5.0.0-beta.2",
"zone.js": "0.5.15",
我TSD:
{
"version": "v4",
"repo": "borisyankov/DefinitelyTyped",
"ref": "master",
"path": "typings",
"bundle": "typings/tsd.d.ts",
"installed": {
"jquery/jquery.d.ts": {
"commit": "9027703c0bd831319dcdf7f3169f7a468537f448"
},
"bootstrap/bootstrap.d.ts": {
"commit": "9027703c0bd831319dcdf7f3169f7a468537f448"
}
},
"ambientDependencies": {
"es6-shim": "github:DefinitelyTyped/DefinitelyTyped/es6-shim/es6-shim.d.ts#6697d6f7dadbf5773cb40ecda35a76027e0783b2"
}
}
我的靴子:
///<reference path="../../node_modules/angular2/typings/browser.d.ts"/>
import {bootstrap} from 'angular2/platform/browser'
import {AppComponent} from './app.component'
import {ROUTER_PROVIDERS} from 'angular2/router';
import {HTTP_PROVIDERS} from 'angular2/http'
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/retry';
bootstrap(AppComponent, [ROUTER_PROVIDERS, HTTP_PROVIDERS]);
我的路由類:
import {Component} from 'angular2/core';
import {RouteConfig, Router, Location, Instruction, ROUTER_DIRECTIVES} from 'angular2/router';
import {MainComponent} from './components/sections/main.component';
import {NotFoundComponent} from './components/sections/not-found.component';
import {EventEmitterService} from './services/event-emitter.service';
import {NavigationService, Routes} from './services/navigation.service';
@Component({
selector: 'my-app',
template: '<router-outlet></router-outlet>',
directives: [ROUTER_DIRECTIVES],
providers: [EventEmitterService, NavigationService]
})
@RouteConfig([
{path:'/' , name: Routes.Main , component: MainComponent, useAsDefault: true},
{path:'/not-found' , name: Routes.NotFound , component: NotFoundComponent}
])
export class AppComponent
{
public constructor(private _router: Router, _location:Location)
{
_router.recognize(_location.path()).then((instruction: Instruction) => {
if (!instruction)
_router.recognize('/not-found').then((instruction: Instruction) => _router.navigateByInstruction(instruction, true));
});
}
}
回到beta0一切正常。 我想了解發生了什麼問題。我不認爲我是唯一有這個問題的人。我的代碼嚴格遵循教程的代碼 – user3471528