装饰器

110 阅读1分钟

1.可以修饰类属性 类原型的方法

2.修饰的时候 把这个类属性传递给修饰函数

class Person{
  name:"lily";
  address(a,b){
  	console.log(a,b)
  }
}
function flag(value){
  console.log(1)
  return function(constructor){
    constructor.type = value
  }
}
flag("工程师1")(Person)

console.log(Person)