我是sencha的新手。我正在尝试向面板添加图标,但我的代码不起作用。
Ext.define('components.ImagePanel', {
extend: 'Ext.Panel',
initialize: function () {
this.callParent(arguments);
var image = {
xtype: "image",
src: 'icon.png',
width:100,
height:100
},
scope: this
};
this.add([image]);
});
我做错了什么?
答案 0 :(得分:0)
无论如何......
要使用xtype,您需要使用Ext.widget();
所以你的代码应该是这样的:
Ext.define('components.ImagePanel', {
extend: 'Ext.Panel',
initialize: function () {
this.callParent(arguments);
var image = Ext.widget('image',{
xtype: "image",
src: 'icon.png',
width:100,
height:100
});
this.add([image]);
};
});