尽管我从 angular2/core 导入了组件,但我还是收到了这种错误,它的来源应该是文件不是通过 npm install 下载的,或者我的 Node 需要升级
这是我的文件
import {bootstrap} from 'angular2/platform/browser';
import {Component, View} from 'angular2/core';
@Component({
})
最佳答案
在组件之后定义一个类。
import {bootstrap} from 'angular2/platform/browser';
import {Component, View} from 'angular2/core';
@Component({
})
class MyClass {
}
@Component
只是一个包含类元数据的装饰器。换句话说,它只是以更优雅的方式为您的类定义内容。
The @Component function takes the configuration object and turns it into metadata that it attaches to the component class definition. Angular discovers this metadata at runtime and thus knows how to do "the right thing".
关于node.js - 带有 TypeScript : Declaration expected compiler error after @component 的 Angular2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34824854/