Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
图像组件ExtJS 4.2上不允许使用setSrc()函数_Extjs_Extjs4_Extjs4.2 - Fatal编程技术网

图像组件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');

是的,完全忘记了查询功能。谢谢