Use mixins in ExtJS4 to implement multi-Inheritance
Use mixins in ExtJS4 to implement multi-inheritance. The following is a good example. If you are interested, refer
Use mixins in ExtJS4 to implement multi-inheritance. The sample code is as follows:
The Code is as follows:
(Function (){
Ext. onReady (function (){
Ext. define ('say ',{
CanSay: function (){
Alert ("hello ");
}
});
Ext. define ('eat ',{
Caneat: function (){
Alert ("eating ");
}
});
Ext. define ("user ",{
Mixins :{
Csay: 'say ',
Ceat: 'eat'
}
});
Var ss = Ext. create ("user ",{});
Ss. caneat ();
Ss. canSay ();
});
})();
Note the difference between mixins and extend. extend can only implement Single inheritance, because the parameters following extend can only be a String type, and files cannot be separated by commas.
In mixins, multiple classes can be loaded to achieve multi-inheritance.