You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit de57ffb
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: JavaScript/TypeScript/类型使用/Decorator.md
+89-1Lines changed: 89 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -106,6 +106,7 @@ function foo(target) {
106
106
}
107
107
};
108
108
}
109
+
109
110
@foo
110
111
classP {
111
112
constructor() {}
@@ -160,6 +161,8 @@ p.test('Hello Jony');
160
161
161
162
所谓注解的定义就是:为相应的类附加元数据支持。所谓元数据可以简单的解释,就是修饰数据的数据,比如一个人有 name,age 等数据属性,那么 name 和 age 这些字段就是为了修饰数据的数据,可以简单的称为元数据。通过注解添加元数据,然后在装饰器中获取这些元数据,完成对类、类的方法等等的修改,可以在装饰器中添加元数据的支持,比如可以可以在装饰器工厂函数以及装饰器函数中添加元数据支持等。
162
163
164
+
## 注解使用
165
+
163
166
Reflect Metadata 是 ES7 的一个提案,它主要用来在声明的时候添加和读取元数据。Reflect Metadata 的 API 可以用于类或者类的属性上,如:
0 commit comments