我已经创建了一个包含项目的面板,我还想向其中添加图像,这是代码。 (后来我将此面板添加到新窗口中)。
var frmCar = Ext.create('Ext.form.Panel',{
bodyPadding: 5,
frame : true,
items :[
{
xtype : 'textfield',
fieldLabel : 'Number: ',
name : 'number'
},,
{
xtype : 'textfield',
fieldLabel : 'Model: ',
name : 'model'
},{
xtype : 'textfield',
fieldLabel : 'Image path: ',
name : 'image'
},
{ xtype: 'image',
width: 200,
height: 400,
src: 'c:/image1.jpg'
}
]
});
面板显示所有元素 - 但不显示图像,我做错了什么? 另外,我想让用户输入图像路径 - 那么我是否必须将单路径分隔符替换为双路径分隔符?例如/到此//?
最佳答案
extJS 部分看起来不错。问题可能是,如果您从网络服务器运行页面,则无法从硬盘访问图像。
尝试将图像放入可通过 HTTP 访问的文件夹中,并使用相对 URL 而不是文件路径。 或者尝试使用互联网上的图像(例如 https://www.google.fr/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png )来测试它是否显示。
关于javascript - 无法在 extJS 中显示图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37393709/