nextjs 的函数,参数,属性装饰器的使用
// 属性装饰器 const doc1:PropertyDecorator = (target:any,val: string | symbol) => { console.log(target); console.log(val); val = "覆盖"; } // 方法装饰器 const doc2: MethodDecorator = (target:any,val: string | symbol,desc:any) => { console.log(target,val,desc); } // 参数装饰器 const doc3: ParameterDecorator = (target:any,val: string | symbol,index:any) => { console.log(target,val,index); } class Zlx{ @doc1 public name : string; constructor(){ this.name = "小龙"; } @doc2 getName(name:string,@doc3 age:number){ } } const z1 = new Zlx(); console.log(z1.name);