ExtjS學習--------Ext.define定義類

來源:互聯網
上載者:User

標籤:set   code   中文版   檔案   this   created   blank   查看   read   

Ext類Class的配置項:(註:Extjs的 的中文版協助文檔:http://download.csdn.net/detail/z1137730824/7748893 

ExtJS設定檔和示範範例的:http://download.csdn.net/detail/z1137730824/7754771)



文法:

define( String className, Object data, Function createdFn )

執行個體:

Ext.onReady(function(){//文法:define( String className, Object data, Function createdFn )Ext.define(‘Person‘,{//對於類的配置資訊//config屬性:配置當前類的屬性內容。而且會自己主動加入get和set方法config:{name:‘張三‘,age:30},//自訂的方法myMethod:function(){alert(‘這是自訂的方法‘);},//給當前定義的類加入構造器constructor:function(config){var me=this;//擷取當前的類//能夠查看配置項中的內容//for(var attr in config)//{//alert(attr+":"+config[attr]);//}me.initConfig(config);//對傳遞進來的參數進行真正的初始化}});//Ext推薦的執行個體化對象的方法:Ext.Createvar p=Ext.create(‘Person‘,{//自訂的類的類名name:‘執行個體化名字‘,//配置項age:100});alert(‘名字:‘+p.getName()+‘--age:‘+p.getAge());//調用預設加入的get方法p.myMethod();//調用自訂的方法});
執行結果;

     


ExtjS學習--------Ext.define定義類

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.