如何在 Sencha Touch 中显示图像?
因此,我在 Sencha Touch 中有一个面板,并且有一个图像,我想将其显示为该面板中的组件。我已经尝试了以下几件事:
logo = {
xtype: 'component',
autoEl: {
src: 'http://addressofmyimage.com/image.png',
tag: 'img',
style: { height: 100, width: 100 }
}
};
然后将上述组件添加为面板中的项目。不显示图像。我的所有其他组件都会显示,但不会显示图像。甚至没有一个损坏的图像链接图标。我无法弄清楚这一点...
我不想只插入原始 html,因为我无法按照我的意愿对其进行格式化。
So, I have a panel in Sencha Touch and I have an image which I want to display as a component in that panel. I have tried several things along the lines of:
logo = {
xtype: 'component',
autoEl: {
src: 'http://addressofmyimage.com/image.png',
tag: 'img',
style: { height: 100, width: 100 }
}
};
Then adding above component as an item in my panel. No image is displayed. All of my other components are displayed but not the image. Not even a broken-image-link icon. I can't figure this out...
I'd rather not just insert raw html, as I cannot format that as I wish.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用面板来显示图像本身可能会更好。将上面的代码替换为...
Probably better off using a panel to display the image itself. Replace the above code with...
您可以重写组件的 getElConfig 方法并返回 autoEl 对象中的内容。
当渲染组件以获取底层元素的构成时,将使用该方法。
You could override the Component's getElConfig method and return what you have in your autoEl object.
That method is used when the component is rendered to get the makeup of the underlying element.
您可以使用 src.sencha.io API 根据需要调整图像大小。下面的例子对我有用。
您可以在此处找到文档。
You can use src.sencha.io API to resize image as you wish. Belowed example works for me.
You can find documentation here.