使用以下扩展便可:
Ext.form.Myimg = Ext.extend(Ext.BoxComponent, { onRender : function(ct, position){ if(!this.el){ this.el = document.createElement('img'); this.el.src = this.src; if(this.forId){ this.el.setAttribute('htmlFor', this.forId); } } Ext.form.Label.superclass.onRender.call(this, ct, position); } }); Ext.reg('myimg', Ext.form.Myimg);
使用:
new Ext.form.Myimg
({
width : 120,
height : 100,
src:'uu.bmp'
}).render(Ext.getBody());
//or
{
xtype : 'myimg',
width : 120,
height : 100,
src:'uu.bmp'
}