Home > Web Front-end > JS Tutorial > body text

Example of using mixins to implement multiple inheritance in ExtJS4_extjs

WBOY
Release: 2016-05-16 17:10:53
Original
1228 people have browsed it

Use mixins to implement multiple inheritance in ExtJS4. The specific example code is as follows:

Copy code 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();
});
})();

One thing to note is mixins The difference from extend is that extend can only implement single inheritance because the parameter followed by extend can only be a string of type String, and files cannot be separated by commas.

Multiple classes can be loaded in mixins to achieve the effect of multiple inheritance.
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template