//装潢器实质是一个函数
//装潢对象能够运用多个装潢器
//装潢器能够带参数
//装潢器润饰类,实例要领
//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);//显现快手直播.