[ExtJS5學習筆記]第十六節 Extjs5使用panel新增的ViewModel屬性綁定資料

來源:互聯網
上載者:User

[ExtJS5學習筆記]第十六節 Extjs5使用panel新增的ViewModel屬性綁定資料

 

 

Sencha ext js 5之前的版本中是沒有viewmodel這個概念的,現在extjs5既然支援mvvm模式了,那麼她的組件也就相應的增加了對mvvm的預設支援。現在看看我們經常使用的panel組件對mvvm模式的強大支援。

先看看文檔對panel的viewmodel屬性的定義:

 

viewModel : String/Object/Ext.app.ViewModelThe ViewModel is a data provider for this component and its children. The data contained in the ViewModel is typically used by adding bind configs to the components that want present or edit this data.When set, the ViewModel is created and links to any inherited viewModel instance from an ancestor container as the parent. The ViewModel hierarchy, once established, only supports creation or destruction of children. The parent of a ViewModel cannot be changed on the fly.If this is a root-level ViewModel, the data model connection is made to this component's associated Data Session. This is determined by calling getInheritedSession.Defaults to: {$value: null, lazy: true}
將上述資訊翻譯一下如下:

 

viewModel:屬性可以設定為字串String或者Object對象或者是Ext.app.ViewModel

ViewModel是這個組件和子構件的資料提供者,ViewModel中包含的資料典型的使用方法就是增加bind配置到想呈現或者編輯資料的組件上。

當設定好了,viewmodel就建立並串連到繼承層次上任何父組件,一旦建立,父組件就無法更改子構件。

如果是根viewmodel,datamodel就關聯到資料節點,這有擷取繼承節點來決定。

預設:{$value:null, lazy:true}

 

簡單說,就是當你想在panle中擷取其他model的data中的資料的時候,就需要制定viewmodel,這有就可以從viewmodel中擷取資料啦。
 

 

聯繫我們

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