dojo 包装器或适配器类
我最近开始使用 dojo,我想知道是否有办法实现包装器/适配器类。在纯 javascript 中,我会执行以下操作:
function Person(name){
this.name=name;
}
function Employee(name,ID){
this.Person=Person;
this.Person(name);
this.ID=ID;
this.PromotedEmployee=PromotedEmployee;
}
function PromotedEmployee(employees){
this.employees=employees; //number of people working for him/her
}
var employee=new Employee("John Stamos",123);
employee.PromotedEmployee(10); //promote to manage 10 people
How do I do this with dojo.这样的东西不起作用
dojo.declare("Person",null,{
constructor: function(name){
this.name=name;
}
});
dojo.declare("PromotedEmployee",null,{
constructor: function(employees){
this.employees=employees;
}
});
dojo.declare("Employee",[Person],{
constructor: function(name,ID){
this.ID=ID;
},
PromotedEmployee=PromotedEmployee;
});
var employee=new Employee("John Stamos",123);
employee.PromotedEmployee(10); //promote to manage 10 people
I have recently started using dojo, I was wondering if there is anyway to implement a wrapper/adapter class. In pure javascript I would do the following
function Person(name){
this.name=name;
}
function Employee(name,ID){
this.Person=Person;
this.Person(name);
this.ID=ID;
this.PromotedEmployee=PromotedEmployee;
}
function PromotedEmployee(employees){
this.employees=employees; //number of people working for him/her
}
var employee=new Employee("John Stamos",123);
employee.PromotedEmployee(10); //promote to manage 10 people
How do I do this with dojo. Something as such does not work
dojo.declare("Person",null,{
constructor: function(name){
this.name=name;
}
});
dojo.declare("PromotedEmployee",null,{
constructor: function(employees){
this.employees=employees;
}
});
dojo.declare("Employee",[Person],{
constructor: function(name,ID){
this.ID=ID;
},
PromotedEmployee=PromotedEmployee;
});
var employee=new Employee("John Stamos",123);
employee.PromotedEmployee(10); //promote to manage 10 people
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
//或者
//OR