这里是我用来显示JSON详细信息的代码,所有细节都正确显示除了图像。当我尝试显示图像时没有显示在图像中。
JSON方法
Ext.Ajax.request({
url: App.gvars.apiurl + 'ShowItemsByItemID/userID='+App.gvars.userid+'/itemID='+itemID, // url : this.getUrl(),
method: "GET",
useDefaultXhrHeader: false,
withCredentials: true,
success: function (response) {
var respObj = Ext.JSON.decode(response.responseText);
Ext.getCmp('myitemname').setValue(respObj[0].itemName);
Ext.getCmp('myitemdesc').setValue(respObj[0].itemDesc);
Ext.getCmp('myitemprice').setValue(respObj[0].itemPrice);
Ext.getCmp('myshopurl').setValue(respObj[0].itemAddress);
Ext.getCmp('myproductpic').setValue(respObj[0].itemImage); //Here the image getting
},
failure: function (response) {
alert(response.responseText);
}
});
这里的小组
{
xtype: 'panel',
height:'100px',
docked: 'bottom',
html:'<div align="center" style="padding-top:30px;"><img src="resources/img/icon1.png" id="myproductpic" /> <img src="resources/img/icon2.png" id="myimglocation" /></div>'
}
如何在'myproductpic'区域显示base64转换后的图像。请帮我解决
答案 0 :(得分:1)
Ext.getCmp() works only for sencha touch components, here you should use
document.getElementById()
还在源
中设置数据类型document.getElementById('myproductpic').src = "data:image/jpeg;base64,"+respObj[0].itemImage;