Sencha Touch - 資料檢視



描述

這是根據儲存值動態建立多個檢視。當我們想要多次顯示同一組件時,我們基本上會使用資料檢視。

語法

以下是建立資料檢視的簡單語法。

Ext.create('Ext.DataView', {})

示例

以下是一個顯示使用方法的簡單示例。

<!DOCTYPE html>
<html>
   <head>
      <link href = "https://cdn.sencha.com/touch/sencha-touch-2.4.2/resources/css/sencha-touch.css" rel = "stylesheet" />
      <script type = "text/javascript" src = "https://cdn.sencha.com/touch/sencha-touch-2.4.2/sencha-touch-all.js">
      </script>
      <script type = "text/javascript">
         Ext.application({
            name: 'Sencha',
            launch: function() {
               var touchTeam = Ext.create('Ext.DataView', {
                  fullscreen: true,

                  store: {
                     fields: ['name', 'age'],
                     data: [
                        {name: 'Greg',  age: 100},
                        {name: 'Brandon',   age: 21},
                        {name: 'Scott',   age: 21},
                        {name: 'Gary', age: 24},
                        {name: 'Fred', age: 24},
                        {name: 'Seth',   age: 26},
                        {name: 'Kevin',   age: 26},
                        {name: 'Israel',   age: 26},
                        {name: 'Mitch', age: 26}
                     ]
                  },

                  itemTpl: '{name} is {age} years old'
               });
            }
         }); 
      </script>
   </head>
   <body>
   </body>
</html>

這會產生以下結果 -

sencha_touch_view_components.htm
廣告