如何在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',
listeners: {
'tap': function () {
Ext.dispatch({
controller: app.controllers.appController,
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'
显然这不起作用,我做错了什么?
答案 0 :(得分:16)
您是否尝试过使用面板本身的add()函数? E.g:
this.add({html: 'test'});