Ext.onReady(function() { alert("測試 config"); //測試 config //構造一臺智能手機 Ext.define('SmartPhone', { config: { hasTouchScreen: false,//有觸摸屏 operatingSystem: 'Other',//操做系統 price: 500//價格 }, constructor: function(cfg) { this.initConfig(cfg); } }); //iPhone手機 var iPhone = new SmartPhone({ hasTouchScreen: true, operatingSystem: 'iOS' }); alert( iPhone.getOperatingSystem()); alert(iPhone.getHasTouchScreen()); //Ext.Msg.alert('iPhone.getPrice():', iPhone.getPrice()); alert("測試 extend"); //測試 extend //構造人類 Ext.define('Person', { say: function(text) { alert(text); }//具備說的方法 }); Ext.define('Developer', { extend: 'Person',//繼承人類 say: function(text) { this.callParent(["print "+text]); }//繼承了說的方法 }); var develop = new Developer(); develop.say("text"); alert("測試 static"); //測試 static //構造一臺計算機 Ext.define('Computer', { statics: { factory: function(brand) { alert(brand); } }, constructor: function() { }//構造函數 }); //建立一臺戴爾電腦 var dellComputer = Computer.factory('Dell'); alert("測試 mixins"); //測試 mixins //唱歌 Ext.define('CanSing', { sing: function() { alert("sing()") } }); //音樂家 Ext.define('Musician', { mixins: ['CanSing'] }); var m = new Musician(); m.sing(); });