ExtJs4學習(五)最基本的Ext類,extjs4學習ext類

來源:互聯網
上載者:User

ExtJs4學習(五)最基本的Ext類,extjs4學習ext類

Ext類是ExtJs中最常見、最基礎的一個類,它是一個全域對象,封裝了所有類、單例和 Sencha 庫所提供的實用方法。


大多數使用者介面組件在一個較低的層次嵌套在命名空間中, 但是提供的許多常見的實用函數作為 Ext 命名空間的直接屬性。


此外提供許多常用的方法,從其他類作為 Ext 命名空間內的捷徑。 例如 Ext.getCmp 就是 Ext.ComponentManager.get 的別名。


一旦DOM準備好,許多應用程式啟動,調用Ext.onReady。 這可以確保已載入所有指令碼, 防止依賴性問題。例如:

Ext.onReady(function(){    new Ext.Component({        renderTo: document.body,        html: 'DOM ready!'    });});

1 apply( Object object, Object config, [Object defaults] ) : Object

參數是拷貝的來源物件,第三個參數是可選的,表示給目標對象提供一個預設值。可以簡單的理解成把第三個參數(如果有的話)及第二個參數中的屬性拷貝給第一個參數對象。

var animal ={name:'tome'}Ext.apply(animal,{age:12,run:function(){console.info('歡樂的跑著')}});
最終animal對象也將擁有run方法,animal.run();


2 applyIf( Object object, Object config ) : Object

和apply基本類似,唯一的區別是,如果object對象已經擁有某屬性或方法,config不再進行覆蓋


3 decode( String json, Boolean safe ) : Object

Ext.JSON.decode的簡寫形式 解碼(解析)JSON字串對象。如果JSON是無效的,這個函數拋出一個SyntaxError,除非設定了安全選項。

var result = Ext.decode('{success:true,msg:xxxx}');console.info(result.success)//true
4 each( Array/NodeList/Object iterable, Function fn, [Object scope], [Boolean reverse] ) : Boolean

Ext.each([1,2,3,4,5,6],function(item,index,allItems){if(item<5){return false;}else{console.log(item);}});


5  fly( String/HTMLElement dom, [String named] ) : Ext.dom.AbstractElement.Fly

get( String/HTMLElement/Ext.Element el ) : Ext.dom.Element

getCmp( String id )

getDom( String/HTMLElement/Ext.Element el )

query( String path, [HTMLElement root], [String type] ) : HTMLElement[]

select( String selector ) : Ext.CompositeElement

以上在ExtJs4學習(二):Dom操作 已有介紹


6 isArray( Object target ) : Boolean

isBoolean( Object value ) : Boolean

isDate( Object object ) : Boolean

isElement( Object value ) : Boolean

isEmpty( Object value, Boolean allowEmptyString ) : Boolean

isFunction( Object value ) : Boolean

isIterable( Object value ) : Boolean

isNumber( Object value ) : Boolean

isNumeric( Object value ) : Boolean

isObject( Object value ) : Boolean

isPrimitive( Object value ) : Boolean

isString( Object value ) : Boolean

isTextNode( Object value ) : Boolean

以上基本都是對象的判斷,可以參考API


7 namespace( String... ) : Object

Ext.namespace('my.app.service');my.app.service.name = 'somnus';my.app.service.say = function(){console.info('hello')}
8 ns( String... ) : Object

namespace的簡寫形式


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.