[英]What is the @ symbol in TypeScript?
Why in components or directives do the metadata or decorators have the @
symbol (eg @Component
, @Directive
)?为什么在组件或指令中元数据或装饰器有@
符号(例如@Component
Component、@ @Directive
)?
What is the purpose of it, and when should I use it?它的目的是什么,我应该什么时候使用它?
It stands for decorators.它代表装饰器。 It is not TypeScript specific.它不是特定于 TypeScript 的。
Google "javascript decorator" to learn more about it.谷歌“javascript decorator”以了解更多信息。
For example:例如:
http://javascript.info/tutorial/decorators http://javascript.info/tutorial/decorators
https://medium.com/google-developers/exploring-es7-decorators-76ecb65fb841#.jzu13e5lr https://medium.com/google-developers/exploring-es7-decorators-76ecb65fb841#.jzu13e5lr
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有关其标准实现及其最终发布时间(未来的 ECMAScript 版本)的最新信息,请参阅此页面: https ://github.com/tc39/proposal-decorators
And as @hardikModha mentioned, you can also look up the TypeScript handbook: http://www.typescriptlang.org/docs/handbook/decorators.html正如@hardikModha 提到的,您还可以查阅 TypeScript 手册: http ://www.typescriptlang.org/docs/handbook/decorators.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.