//装饰器本质是一个函数 //装饰对象可使用多个装饰器 //装饰器能够带参数 //装饰器修饰类,实例方法 //aop 设计思想(log,邮件发送) function school(target){ target.schoolName="快手直播"; } function hometown(diqu){ return function(target){ target.home=diqu; } } function studyke(kemu){ return function(target){ target.ke=kemu; } } @hometown("根里的") @school class Student { constructor(name){ this.name=name; } @studyke("jquery") study(){ console.log(this.name+"在看"+this.ke); } } console.log(Student.schoolName);//显示快手直播. console.log(Student.home);//显示根里的. let l = new Student("曹伟"); l.study();//显示曹伟再看jquery. @school class Teacher { } console.log(Teacher.schoolName);//显示快手直播.