2012-03-12 69 views
3

試圖跟隨這裏的視頻http://docs.sencha.com/touch/2-0/#!/guide/getting_started,但一旦它到達添加xtypes將所有內容放在一起大約3分鐘的部分。我無法讓xtype正常工作,在這裏就是我有我的Main.jsSencha Touch 2.0 xtype不起作用

Ext.define("GS.view.Main", { 
    extend: 'Ext.tab.Panel', 
    requires: ['Ext.TitleBar'], 

    config: { 
      tabBarPosition: 'bottom', 

      items:[ 
        { 
        xtype: 'homepanel', 
        } 
    ] 
    } 
}); 

這是我在我的Home.js文件

Ext.define("GS.view.Home", { 
    extend: 'Ext.tab.Panel', 
    requires: ['Ext.TitleBar'], 
    xtype: 'homepanel', 

    config: { 
    tabBarPosition: 'bottom', 

    items: [ 
     { 
      title: 'Welcome', 
      iconCls: 'home', 
      cls:'home', 
      styleHtmlContent: true, 
      scrollable: true, 



      html: [ 
       '<img src="http://staging.sencha.com/img/sencha.png" />', 
       '<h1>Welcome to Sencha Touch</h1>', 
       "<p>You'rebbb creating the Getting Started app. This demonstrates how ", 
       "to use tabs, lists and forms to create a simple app</p>", 
       '<h2>Sencha Touch (2.0.0)</h2>' 
      ].join("") 
     }] 
    } 
}); 

和我有這個

views: [ 'Main', 'Home', 'Contact' ], 
的app.js

我做了什麼視頻在做什麼,也許我錯過了什麼?預先感謝您的幫助。

回答

1

您需要在類定義中使用別名屬性。

Ext.define("GS.view.Home", { 
    extend: 'Ext.tab.Panel', 
    requires: ['Ext.TitleBar'], 
    alias: 'widget.homepanel', 

    config: { 
     tabBarPosition: 'bottom', 
     items: [{ 
      title: 'Welcome', 
      iconCls: 'home', 
      cls:'home', 
      styleHtmlContent: true, 
      scrollable: true, 
      html: [ 
       '<img src="http://staging.sencha.com/img/sencha.png" />', 
       '<h1>Welcome to Sencha Touch</h1>', 
       "<p>You'rebbb creating the Getting Started app. This demonstrates how ", 
        "to use tabs, lists and forms to create a simple app</p>", 
        '<h2>Sencha Touch (2.0.0)</h2>' 
      ].join("") 
     }] 
    } 
}); 
+0

即時通訊新的ST和遇到同樣的問題。你能否詳細說明爲什麼會出現這種情況? – 2012-04-17 21:07:01

0

這可能是因爲你試圖在你的Home.js中擴展:Ext.tab.Panel。

這樣做會使您看起來像在選項卡面板中添加選項卡面板。

儘量延長:「Ext.Panel」,你Home.js應該做的,或者你也可以使用

擴展:「Ext.Container」,