ExtJS learn-------ext.define aliases and alternate names, two methods for defining static methods, mixed with properties and other properties

Source: Internet
Author: User
Tags aliases

(1) Ext.define alias and alternate name

Ext.onready (function () {ext.define (' User ', {config:{name: ' Zhang San ', age:23},//using aliases alias: ' Alias_user ',// Use alternate name alternateclassname: ' Alternateclassname_user ', constructor:function (config) {//constructor var me=this;me.initconfig ( config);}); /define VAR u1=ext.create (' User ') with three names, Var u2=ext.create (' Alias_user '), var u3=ext.create (' Alternateclassname_user '); Alert (U1.getname () + ' = = ' +u1.getage ()), Alert (u2.getname () + ' = = ' +u1.getage ()), Alert (u3.getname () + ' = = ' +u1.getage ()) ;});

Results:


(2) Defining static methods (two methods)


Ext.onready (function () {ext.define (' person ', {config:{name: ' Zhang San '},statics:{//static method or property static_id: ' I am the ID of the person, cannot be overridden by a class that inherits the '},inheritablestatics:{//static method or property inheritablestatics_id: ' I am the ID of the person, I can inherit the quilt Class! '},constructor: Function (config) {var me = this;me.initconfig (config);}}); Ext.define (' User ', {extend: ' person ', config:{age:23}});//Test the inherited static property: the instance object is unable to use the static property or method//using the class name to use the static property or method alert ( USER.STATIC_ID); alert (user.inheritablestatics_id); alert (person.static_id);});

Results:


(3) Mixed attribute, equivalent to multiple inheritance:

Ext.onready (function () {ext.define (' boy ', {boysay:function () {alert (' I am a boy ... ');}}); Ext.define (' Girl ', {girlsay:function () {alert (' I am a Girl ... ');}}); Ext.define (' person ', {mixins:{//is mixed with the attribute, which is equivalent to multiple-inheritance boy: "Boy", Girl: "Girl"}}), Var p=ext.create (' person ');p. Boysay (); P.girlsay ();});

Results:


(4) other properties of Ext.define:






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.