(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: