1
法「createChild所」我寫了這樣的定義ExtJS4類:錯誤:無法調用未定義
Ext.define('Ext.ux.PictureBox', {
extend: 'Ext.panel.Panel',
alias: 'widget.picturebox',
url: "",
afterRender: function() {
this.callParent();
this.imageEl = Ext.DomHelper.append(this.body, Ext.String.format("<img style='width:{0}px;height:{1}px' src='{2}' />", this.width, this.height, this.url), true);
this.items.items[0].addCls('browse-picture-button');
this.items.items[1].addCls('remove-picture-button');
},
initComponent: function() {
var conf = {
items:[
{
itemid: 'browseBtn',
xtype: 'fileuploadfield',
name: 'photo',
buttonText: '...',
buttonOnly: true,
text: '...',
width: 30,
height: 20
},
{
itemid: 'removeBtn',
xtype: 'button',
text: 'X',
width: 30,
height: 20
}
]
};
Ext.apply(this, Ext.apply(this.initialConfig, conf));
this.callParent(arguments);
},
setSize: function (w, h) {
this.callParent();
if (this.imageEl) {
this.imageEl.setSize(w, h);
}
},
setUrl: function (url) {
this.url = url;
if (this.rendered) {
this.imageEl.dom.src = url;
}
}
});
然後,我創建這個類:
Ext.create('Ext.ux.PictureBox', {
width: 300,
height: 300,
url: 'http://blogs-images.forbes.com/daviddisalvo/files/2012/01/googlelogo2.jpg',
renderTo: Ext.getBody()
});
而且腳本拋出錯誤無法調用「 createChild'的undefined。爲什麼?
如果我用'button'代替fileuploadfield,那麼一切正常,
宥可以看到,在這裏運行這個例子http://jsfiddle.net/C3HEu/12/