【发布时间】:2016-05-16 02:18:21
【问题描述】:
有谁知道为什么在我的 Angular2 应用程序中第一次加载页面时出现此错误?当我浏览我的应用程序时,它会清除并且不会回来。如果我按 CTRL+F5,它往往会回来(尽管不是每次!)。此应用的路由如下所示:
AppComponent.ts
LoginComponent.ts
DashboardComponent(Parent route with its own child routes)
MainDashboardComponent
EmployeesComponent
顶级 index.html 文件中包含 <my-app></my-app> 标记,该错误会定期抱怨,所以我很困惑它怎么可能在页面上看不到该标记!
错误详情:
例外:选择器“my-app”不匹配任何元素BrowserDomAdapter.logError @ angular2.dev.js:22823BrowserDomAdapter.logGroup @ angular2.dev.js:22834ExceptionHandler.call @ angular2.dev.js:1163(匿名函数) @ angular2.dev.js:12481NgZone._notifyOnError @ angular2.dev.js:13405collection_1.StringMapWrapper.merge.onError @ angular2.dev.js:13309run @ angular2-polyfills.js:141(匿名函数) @ angular2.dev。 js:13328zoneBoundFn @ angular2-polyfills.js:111lib$es6$promise$$internal$$tryCatch @ angular2-polyfills.js:1511lib$es6$promise$$internal$$invokeCallback @ angular2-polyfills.js:1523lib$es6$ promise$$internal$$publish @ angular2-polyfills.js:1494(匿名函数) @ angular2-polyfills.js:243microtask @ angular2.dev.js:13360run @ angular2-polyfills.js:138(匿名函数) @ angular2。 dev.js:13328zoneBoundFn @ angular2-polyfills.js:111lib$es6$promise$asap$$flush @ angular2-polyfills.js:1305 angular2.dev.js:22823 STACKTRACE:BrowserDomAdapter.logError @ angular2.dev.js:22823ExceptionHandler.call @ angular2.dev.js:1165(匿名函数) @ angular2.dev.js:12481NgZone._notifyOnError @ angular2.dev.js :13405collection_1.StringMapWrapper.merge.onError @ angular2.dev.js:13309run @ angular2-polyfills.js:141(匿名函数) @ angular2.dev.js:13328zoneBoundFn @ angular2-polyfills.js:111lib$es6$promise$$内部$$tryCatch @ angular2-polyfills.js:1511lib$es6$promise$$internal$$invokeCallback @ angular2-polyfills.js:1523lib$es6$promise$$internal$$publish @ angular2-polyfills.js:1494(匿名函数)@angular2-polyfills.js:243microtask@angular2.dev.js:13360run@angular2-polyfills.js:138(匿名函数)@angular2.dev.js:13328zoneBoundFn@angular2-polyfills.js:111lib$es6$promise $asap$$flush @ angular2-polyfills.js:1305 angular2.dev.js:22823 错误:选择器“my-app”不匹配任何元素 在新的 BaseException (http://localhost:3000/node_modules/angular2/bundles/angular2.dev.js:7104:21) 在 DomRenderer.selectRootElement (http://localhost:3000/node_modules/angular2/bundles/angular2.dev.js:13724:15) 在 HostViewFactory.viewFactory_HostAppComponent0 [as viewFactory] (viewFactory_HostAppComponent:72:18) 在 AppViewManager_.createRootHostView (http://localhost:3000/node_modules/angular2/bundles/angular2.dev.js:9226:34) 在http://localhost:3000/node_modules/angular2/bundles/angular2.dev.js:12246:46 在 Zone.run (http://localhost:3000/node_modules/angular2/bundles/angular2-polyfills.js:138:17) 在 Zone.run (http://localhost:3000/node_modules/angular2/bundles/angular2.dev.js:13328:32) 在 zoneBoundFn (http://localhost:3000/node_modules/angular2/bundles/angular2-polyfills.js:111:19) 在 lib$es6$promise$$internal$$tryCatch (http://localhost:3000/node_modules/angular2/bundles/angular2-polyfills.js:1511:16) 在 lib$es6$promise$$internal$$invokeCallback (http://localhost:3000/node_modules/angular2/bundles/angular2-polyfills.js:1523:17)
-----异步间隙----- 错误 在 _getStacktraceWithUncaughtError (http://localhost:3000/node_modules/angular2/bundles/angular2-polyfills.js:2195:26) 在 Zone.fork (http://localhost:3000/node_modules/angular2/bundles/angular2-polyfills.js:2253:40) 在 Zone.bind (http://localhost:3000/node_modules/angular2/bundles/angular2-polyfills.js:109:48) 在 bindArguments (http://localhost:3000/node_modules/angular2/bundles/angular2-polyfills.js:980:29) 在 lib$es6$promise$promise$$Promise.obj.(匿名函数) [as then] (http://localhost:3000/node_modules/angular2/bundles/angular2-polyfills.js:1000:37) 在 DynamicComponentLoader_.loadAsRoot (http://localhost:3000/node_modules/angular2/bundles/angular2.dev.js:12245:49) 在 di_1.provide.useFactory (http://localhost:3000/node_modules/angular2/bundles/angular2.dev.js:12343:39) 在 Injector._instantiate (http://localhost:3000/node_modules/angular2/bundles/angular2.dev.js:11354:19) 在 Injector._instantiateProvider (http://localhost:3000/node_modules/angular2/bundles/angular2.dev.js:11287:21) 在 Injector._new (http://localhost:3000/node_modules/angular2/bundles/angular2.dev.js:11277:19)
-----异步间隙----- 错误 在 _getStacktraceWithUncaughtError (http://localhost:3000/node_modules/angular2/bundles/angular2-polyfills.js:2195:26) 在 Zone.fork (http://localhost:3000/node_modules/angular2/bundles/angular2-polyfills.js:2253:40) 在 NgZone._createInnerZone (http://localhost:3000/node_modules/angular2/bundles/angular2.dev.js:13316:39) 在新的 NgZone (http://localhost:3000/node_modules/angular2/bundles/angular2.dev.js:13182:32) 在 createNgZone (http://localhost:3000/node_modules/angular2/bundles/angular2.dev.js:12365:12) 在 PlatformRef_.application (http://localhost:3000/node_modules/angular2/bundles/angular2.dev.js:12440:31) 在 Object.bootstrap (http://localhost:3000/node_modules/angular2/bundles/angular2.dev.js:24543:64) 执行时 (http://localhost:3000/app/main.js:15:23) 在 ensureEvaluated (http://localhost:3000/node_modules/systemjs/dist/system.src.js:3202:26) 在 Object.execute (http://localhost:3000/node_modules/systemjs/dist/system.src.js:3323:13)BrowserDomAdapter.logError@angular2.dev.js:22823ExceptionHandler.call@angular2.dev.js:1166(匿名函数)@angular2.dev.js:12481NgZone._notifyOnError@angular2.dev.js:13405collection_1.StringMapWrapper .merge.onError @ angular2.dev.js:13309run @ angular2-polyfills.js:141(匿名函数) @ angular2.dev.js:13328zoneBoundFn @ angular2-polyfills.js:111lib$es6$promise$$internal$$tryCatch @ angular2-polyfills.js:1511lib$es6$promise$$internal$$invokeCallback @ angular2-polyfills.js:1523lib$es6$promise$$internal$$publish @ angular2-polyfills.js:1494(匿名函数)@ angular2 -polyfills.js:243microtask @ angular2.dev.js:13360run @ angular2-polyfills.js:138(匿名函数) @ angular2.dev.js:13328zoneBoundFn @ angular2-polyfills.js:111lib$es6$promise$asap$$冲洗@ angular2-polyfills.js:1305
【问题讨论】:
-
我想这需要更多信息。你能创建一个 Plunker 吗?
-
@emirhosseini.. 这需要更多代码。你能发布你的组件代码吗?