Extjs-define defines a class __js

Source: Internet
Author: User
If you want to learn ExtJS well, it is necessary for JavaScript, that is, understanding the ExtJS underlying infrastructure. So now we're going to start learning the EXTJS infrastructure.
How to create an ext class, create a complex flow of classes
-Deep analysis of ext.js and Ext-more.js
-Ext extensions to native JavaScript classes
-EXT Operations DOM

-Ext starts responding to events

ways to define classes: Define
For the ext4.x version, the Define method of the new definition class is adopted, rather than the extend method that extends the old version, then for the definition of a new class. Let's take a look at the use of define.
Ext.define (Classname,properties,callback);
-ClassName: Class name of the new class to be defined
-Properties: Configuration object for new class
-Callback: callback function that executes when the class is created
For ext to define a new class, then we can imagine that Since it is the use of ext.define to create classes, then the class created must be the class of ext, different from the traditional JavaScript to create a class, that is, we want to the Define method of the second parameter properties configuration items, we need to find Ext for class-supported APIs and configure

[JavaScript]  View plain Copy ext.onready (function () {          // How to define a class in Ext: Ext.define (classname,properties,callback)        ext.define (' person ', {       //Here is some configuration information for this class (see Ext.class configs)        The      //config property is to configure the property contents of the current class and add the Get and set methods             config:{                Name: ' Z3 ',               age:20            },            //own defined methods            say:function () {                alert (' I am the method ... ');         &Nbsp; },           //adds a constructor to the currently defined class to initialize the information             constructor:function (config) {                var me = this;                for (var attr in config) {    //Loop shows the parameters passed in                     alert (attr +  ': '  + config[attr]);                }                me.initconfig (config);    //true initialization passes in parameters             }      &nbsp});           &NBsp;   var p = new person ();  //  alert (p.name);   //  alert (p.age);       alert (P.getname ());        p.say ();              VAR P1  = new person ({name: ' Li4 ', age:25});  //  alert (p.name);  //   alert (p.age);       alert (P1.getname ());        p1.say ();              //Ext.create  Instantiate an object        var p2 = ext.create (' person ',{        name: ' wang5 ',       age:40       } );       alert (P2.getname ());       p2.say ();   });    for Configs:
-Extend: For inheritance
-Alias: Alias of Class
-Alternateclassname: Alternate name, similar to Alias
-Requires: Class array groups that need to be used to download classes based on this property on dynamic loading, noting that the required classes are loaded before the current class
-Uses: Similar to requires but referenced classes can be loaded after the class
-Constructor: constructor properties, typically used to initialize the configuration of a class and to invoke its parent class
-mixins: Mixed attributes, multiple inheritance
-config: Defines a configuration item for a class that adds each property in config to the get and set methods
-statics: Define static methods, attributes cannot inherit from quilt class

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.