Angular2异常:必须定义令牌
发布时间:2020-12-17 09:17:47 所属栏目:安全 来源:网络整理
导读:应用程序/ boot.ts import {bootstrap} from 'angular2/platform/browser';import {AppComponent} from './app.component';bootstrap(AppComponent); 应用程序/ app.component.ts import {Component} from 'angular2/core';@Component({ selector: 'my-app',
应用程序/ boot.ts
import {bootstrap} from 'angular2/platform/browser'; import {AppComponent} from './app.component'; bootstrap(AppComponent); 应用程序/ app.component.ts import {Component} from 'angular2/core'; @Component({ selector: 'my-app',template: '{{title}}' }) class AppComponent { title: "app" } 错误: EXCEPTION: Token must be defined! STACKTRACE:BrowserDomAdapter.logError @ angular2.dev.js:23514 ExceptionHandler.call @ angular2.dev.js:1147 (anonymous function) @ angular2.dev.js:14801 NgZone._notifyOnError @ angular2.dev.js:5796 collection_1.StringMapWrapper.merge.onError @ angular2.dev.js:5700 run @ angular2-polyfills.js:141 (anonymous function) @ angular2.dev.js:5719 NgZone.run @ angular2.dev.js:5681 ApplicationRef_.bootstrap @ angular2.dev.js:14906 bootstrap @ angular2.dev.js:25054 execute @ boot.ts:4 u @ system.src.js:4597 execute @ system.src.js:4597 y @ system.src.js:4597 ...
这是另一个错误,我抓住了我多次.我忘了(再次)导出我的根组件.它应该是:
export class AppComponent { 如果我花时间仔细查看堆栈跟踪(而不是搜索StackOverflow,而不是找到我的确切问题),我会注意到它引用了我写的一个文件boot.ts:4. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |