2012-03-12 71 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”,