Luk*_*lje 15 c# custom-attributes typescript
在C#中,有一种语法可用于定义属性的属性.
[Required]
string personName
Run Code Online (Sandbox Code Playgroud)
它描述了personName是必需的.我们可以通过反射在任何给定时间内获取属性的属性.
我想知道TypeScript是否有这样的功能?
bas*_*rat 12
我想知道TypeScript是否有这样的功能?
装饰师就是这样.例如,mobx(https://github.com/mobxjs/mobx)使用它来使事物可观察.
class TodoList {
@observable todos = [];
@computed get unfinishedTodoCount() {
return this.todos.filter(todo => !todo.finished).length;
}
}
Run Code Online (Sandbox Code Playgroud)