EXTJS4 Self-Study manual--ext Basic Methods, attributes (Mixins multiple inheritance, statics, require)

Source: Internet
Author: User

1.mixins

Description: Similar to multi-inheritance in object-oriented

    <script type= "Text/javascript" >
Ext.onready (function () {
Create a class, class name: Textclass, with two properties: A, B
Ext.define (' Textclass ', {
A: ' A ',
B: ' B '
});
Create a class, class name: Textclass, with two properties: A, B
Ext.define (' TextClass2 ', {
C: ' C ',
Write:function () {
Alert (' A: ' + this. A + '; B: ' + this. B + '; C: ' + this. C
}
})
Ext.define (' TextClass3 ', {
Inherit Textclass, TextClass2
Mixins: {
Textclass: ' Textclass ',
TextClass2: ' TextClass2 '
}
})
var textclass = ext.create ("TEXTCLASS3")
Textclass.write ();

});
</script>

Operation Result:

2.statics

Description: Defining static variables

Example:

    <script type= "Text/javascript" >
Ext.onready (function () {
Create a class, class name: Textclass, with two properties: A, B
Ext.define (' Textclass ', {
A: ' A ',
B: ' B ',
Statics: {
C: ' C '
}
});

No instantiation of the Textclass class
Ext.Msg.alert (the value of the static property C of the ' Textclass class is: ', TEXTCLASS.C)
});
</script>

Execution Result:

3.config

Description: Property wrapper, providing a get and set method for a property

Example:

    <script type= "Text/javascript" >
Ext.onready (function () {
Create a class, class name: Textclass, with two properties: A, B
Ext.define (' Textclass ', {
A: ' A ',
B: ' B ',
Statics: {
C: ' C '
},
Config: {
Configproperty: ' How can I get the property '

}
});
var textclass = ext.create (' Textclass ');
Set the value of the property by the Set method, note that the wrapper will capitalize the first letter of the property
Textclass.setconfigproperty ("Set this property ' s value");
Displaying property values through the Get method
Ext.Msg.alert (the value of the ' Configproperty attribute is: ', Textclass.getconfigproperty ());
});
</script>

Execution Result:

3.ext.require

Description: Dynamic Loading JS file

Using Ext.require to load the JS file, first set the file path through Ext.loader.

Example:

    <script type= "Text/javascript" >
Set the JS file folder under the Ext namespace
Ext.Loader.setPath ({
EXT: ' Http://www.cnblogs.com/Scripts/ext-4.0.7-gpl/ext-4.0.7-gpl/src '
});
Ext.onready (function () {
Load the Ext.window.MessageBox class, located in the Http://www.cnblogs.com/Scripts/ext-4.0.7-gpl/ext-4.0.7-gpl/src/window/MessageBox.js file
Note: A JS file has only one class
Note: Class name = namespace name (This is EXT) + file path name (this is Window/messagebox)
Ext.require ("Ext.window.MessageBox")
});
</script>

Execution Result:

EXTJS4 Self-Study manual--ext Basic Methods, attributes (Mixins multiple inheritance, statics, require)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.