1

我想动态地将新的面板或容器添加到 Ext.tab.Panel。我试过这样的代码:

var panel = Ext.create('Ext.Container');
panel.title = 'From Code';
panel.iconCls = 'home';
panel.styleHtmlContent = true;
panel.html = 'Hello from Code';

tabPanel.add(panel);

但这给了我错误:

Adding a card to a tab container without specifying any tab configuration

我可以使用对象字面量样式添加新的面板或容器,但是当我手动构造一个新对象时该怎么做呢?Ext.Container 类本身没有title 属性。

谢谢!

4

1 回答 1

3

添加 tabPanel 时需要在 Panel 或 Container 中指定 iconCls 和 title 配置

您这样做了,但我认为问题在于您创建容器和设置 iconCls、标题配置的方式。

  var panel = Ext.create('Ext.Container', {
       title: 'From Code', 
       iconCls: 'home', 
       html : 'Hello from Code'
  });



 var tab = Ext.create('Ext.TabPanel', {
    fullscreen: true,
    tabBarPosition: 'bottom',

    defaults: {
        styleHtmlContent: true
    },

    items: [
        {
            title: 'Home',
            iconCls: 'home',
            html: 'Home Screen'
        },
        {
            title: 'Contact',
            iconCls: 'user',
            html: 'Contact Screen'
        }
    ]
});

 tab.add(panel);
于 2013-07-18T06:15:33.133 回答