从JSON分配Base 64转换的图像
这里是我用来显示JSON细节的代码,所有细节都正确显示,除了图像。当我试图显示图像时,它不会显示在图像中 JSON方法从JSON分配Base 64转换的图像,json,extjs,sencha-touch-2,base64,Json,Extjs,Sencha Touch 2,Base64,这里是我用来显示JSON细节的代码,所有细节都正确显示,除了图像。当我试图显示图像时,它不会显示在图像中 JSON方法 Ext.Ajax.request({ url: App.gvars.apiurl + 'ShowItemsByItemID/userID='+App.gvars.userid+'/itemID='+itemID, // url : this.getUrl(), method: "GET", useDefaultXhrHeader: false,
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>'
}
{
xtype:'面板',
高度:'100px',
停靠:“底部”,
html:'
}
如何在“myproductpic”区域显示base64转换后的图像。请帮助我解决此问题
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;
@法齐尔,让我测试一下。将base64字符串发布到此处您可以从pastebin.com获取该字符串/yVkn4rsf@Fazil很抱歉我没能在你的代码中看到一些东西。。请参阅更新