我开始编写 Angular 2 程序,但遇到了一个错误:
ts1206 装饰器在这里无效
@Component({ // ts1206 decorators are not valid here
selector: 'my-app',
moduleId: module.id,
templateUrl: 'app.component.html',
styleUrls: ['app.component.css']
})
Update:
我的 tsconfig.json:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true
}
}
我能用它做什么?
装饰器必须直接位于导出类之前,例如:
@Component({
...
})
export class someComponent{}
这对于@Pipe
@Directive
@Injectable
and @NgModule
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)