装饰器模式

  • 在现有类或对象的基础上,添加了一些功能,使类和对象具有新的表现

    代码实现

1
2
3
4
5
6
7
8
9
10
11
function Path(name: string) {
console.log('需要通过柯里化形式拿到参数,默认传入的是target')
return function (traget: any) {
console.dir(name, traget.age)
}
}

@Path('zhangsan')
class Hello {
public static age: number = 12
}

参考链接