属性装饰器在运行的时候会作为一个函数被调用,传入下面两个参数

    1. 1.对于实例成员是,第一个参数类的原型对象。
    2. 2.第二个参数,是类的属性名
    1. class Student{
    2. @decorateProperty("top250")
    3. public url:string|undefined;
    4. getData(){
    5. console.log(this.url)
    6. }
    7. }
    8. function decorateProperty(parmas:any){
    9. return function(target:any,attr:any){
    10. console.log(target); //类的原型对象
    11. console.log(attr); //属性名
    12. target[attr] = parmas;
    13. }
    14. }
    15. var s:any = new Student();
    16. console.log(s.url);