Sencha Touch动态添加项目

问题描述

| 如何在Ext.panel中动态添加新项目?这是我正在使用的代码
app.views.ViewItem = Ext.extend(Ext.Panel,{
    id: \'0\',dockedItems: [{
        xtype: \'toolbar\',title: \'Melvin test\',items: [
            {
                text: \'Terug\',ui: \'back\',listeners: {
                    \'tap\': function () {
                        Ext.dispatch({
                            controller: app.controllers.appController,action: \'backToRSSList\',animation: {type:\'slide\',direction:\'right\'}
                        });
                    }
                }
            },{xtype:\'spacer\'},{
                id: \'share\',text: \'Delen\',ui: \'action\',action: \'share\',});
                    }
                }
            }
        ]
    }],items: [],initComponent: function() { 
        app.views.ViewItem.superclass.initComponent.apply(this,arguments); 
    },getView: function(data) {
        //this.items.add({html: \'test\'});
    },});
功能getView中,我试图用此行添加一个新项目;
this.items.add({html: \'test\'});
正在显示错误(在Rockmelt,Chrome中)是;
Uncaught TypeError: Object #<Object> has no method \'getItemId\'
显然这不起作用,我在做什么错?     

解决方法

您是否尝试过为面板本身使用add()函数?例如:
this.add({html: \'test\'});