图像组件ExtJS 4.2上不允许使用setSrc()函数
我有一个包含图像组件的字段集:图像组件ExtJS 4.2上不允许使用setSrc()函数,extjs,extjs4,extjs4.2,Extjs,Extjs4,Extjs4.2,我有一个包含图像组件的字段集: { xtype : 'fieldset', title : 'Picture', width : 170, items : [{ xtype : 'image', itemId : 'uploadImage', height : 150, width : 150, src :
{
xtype : 'fieldset',
title : 'Picture',
width : 170,
items : [{
xtype : 'image',
itemId : 'uploadImage',
height : 150,
width : 150,
src : ''
}]
}
字段集位于一个别名为:widget.profile的窗口内,因此我使用此行访问图像组件
Ext.ComponentQuery.query('profile [itemId=uploadImage]');
好的,它给了我图像组件,还有函数setSrc(),但我不能使用它,好像对它有权限一样。我做错了什么,或者ExtJS4.2中有错误吗?您的代码
Ext.ComponentQuery.query('profile [itemId=uploadImage]');
返回匹配组件的数组,而不是单个组件。因此,如果您的应用程序中只有一个与查询匹配的组件,则可以通过以下方式获得该组件:
var img = Ext.ComponentQuery.query('profile [itemId=uploadImage]')[0];
然后可以设置图像的src:
img.setSrc('http://www.sencha.com/img/v2/logo.png');
是的,完全忘记了查询功能。谢谢