TypeScript中的@符号是什么? [英] What is the @ symbol in TypeScript?
问题描述
我正在学习Angular,而且我也是TypeScript的新手,所以我的问题是:为什么在组件或指令中,元数据或修饰符会带有"@"符号,例如 @Component
/ @Directive
.
I´m learning Angular and I´m new with TypeScript too, so my question is:
why in components or directives do the metadata or decorators have the "@" symbol like this @Component
/@Directive
.
它的目的是什么,什么时候应该使用它?
What is the purpose of it, and when should I use it?
推荐答案
它代表装饰器.它不是TypeScript专用的.
It stands for decorators. It is not TypeScript specific.
Google"javascript装饰器"进一步了解它.
Google "javascript decorator" to learn more about it.
例如:
http://javascript.info/tutorial/decorators
https://medium.com/google-developers/Exploration-es7-decorators-76ecb65fb841#.jzu13e5lr
有关其标准实现以及何时最终发布(最新的ECMAScript版本)的最新信息,请参阅以下页面: https://github.com/tc39/proposal-decorators
For up to date information about their standard implementation and when it will finally be released (future ECMAScript versions), see this page: https://github.com/tc39/proposal-decorators
正如@hardikModha所提到的,您还可以查阅TypeScript手册: http://www.typescriptlang.org/docs/handbook/decorators.html
And as @hardikModha mentioned, you can also look up the TypeScript handbook: http://www.typescriptlang.org/docs/handbook/decorators.html
这篇关于TypeScript中的@符号是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!