作用于方法及构造函数的参数,在参数的左边声明

    1. function decorator ( target: Function , name: string, index: number ) {}
    • 参数说明
      • target:静态成员:类的构造函数;实例成员:类的原型对象
      • name:方法的成员名称
      • index:在所有形参中的索引
    • 参数装饰器的返回值会被忽略

    实例

    1. function decorator () {
    2. return function ( target: Function , name: string, index: number ) {
    3. console.log(`this params is ${ index + 1 } of ${ name }`)
    4. }
    5. }
    6. class ClassName {
    7. method( @decorator() params: number ): void { }
    8. }