2013-05-08 38 views
0

我是Sencha Touch的新手,雖然我對MVC知之甚少,但在嘗試時遇到錯誤來構建應用程序以下煎茶的視頻教程觸摸2爲:Uncaught-TypeError-Can not-call-method-substring-of-undefined-sencha-touch-all.js

Uncaught TypeError: Cannot call method 'substring' of undefined sencha-touch-all.js:35

的代碼如下:

app.js:

Ext.Loader.setConfig({ 
    enabled: true 


}); 
Ext.application({ 
    name: 'SBR', 
    controllers: [ 
     'Main' 
    ], 
    launch: function(){ 
     Ext.create('Ext.TabPanel',{ 
      fullscreen: true, 
      tabBarPosition: 'bottom', 
      items: [ 
      { 
       xtype: 'homepanel' 
      }, 
      { 
       xtype: 'carousel', 
       title: 'Blog', 
       iconCls: 'star', 
       html: 'Student Blog', 
       items: [ 
       { 
        xtype: 'image', 
        src: 'resources/images/icon1.png' 
       }, 
       { 
        xtype: 'image', 
        src: 'resources/images/icon2.png' 
       }] 

      }, 
      { 

       title: 'Enter your Comments', 
       iconCls: 'star', 
       html: 'Enter your Comments' 
      } 

      ] 

     }); 
    } 
}); 

Home.js - 視圖

Ext.define('SBR.view.Home', { 
    extend: 'Ext.Panel', 
    xtype: 'homepanel', 
    config:{ 
     title: 'Home', 
     iconCls: 'home', 
     html: 'Html through View' 
    } 
}); 

Main.js - 控制器

​​

如果視圖的代碼(Home.js)在app.js設置不使用的xtype,它工作得很好,但是當我定義一個視圖並嘗試從app.js通過xtype訪問視圖,它不起作用並拋出上述異常,儘管它在控制檯中成功記錄傳遞到控制器中的消息。你添加2.0

回答

2

您需要添加所有查看,存儲和模型類在app.js用同樣的方法:

使用的瀏覽器:Chrome的

IDE:集錦

煎茶觸摸版本控制器:

controllers: [ 
     'Main' 
], 
views : [ 
    'Home' 
] 

這應該使它工作。