本文介绍了ts1206装饰器在这里无效,角度2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我开始编写Angular 2并出现错误:
I started to program Angular 2 and I stuck with an error:
@Component({ // ts1206 decorators are not valid here
selector: 'my-app',
moduleId: module.id,
templateUrl: 'app.component.html',
styleUrls: ['app.component.css']
})
更新:
我的tsconfig.json:
My tsconfig.json:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true
}
}
我该怎么办?
推荐答案
装饰器必须直接位于导出的类之前,例如:
The Decorators must come directly before an exported class for example:
@Component({
...
})
export class someComponent{}
@Pipe
@Directive
@Injectable
和@NgModule
这篇关于ts1206装饰器在这里无效,角度2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!