//裝飾器本質是一個函數 //裝飾對象可使用多個裝飾器 //裝飾器能夠帶參數 //裝飾器修飾類,實例方法 //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);//顯示快手直播.