gpt4 book ai didi

sencha-touch-2 - 如何在 Sencha Architect 中动态设置 Ext.Img ->"src"的值

转载 作者:行者123 更新时间:2023-12-04 06:37:25 25 4
gpt4 key购买 nike

我正在使用 ImageView 来显示图像。能否告诉我如何动态设置 url 值,以便我可以为服务器显示图像。下面是我正在尝试的代码。

Ext.define('MyApp.view.MyImage', {
extend: 'Ext.Img',
alias: 'widget.myimage',

config: {
height: 201,
id: 'galimage',
width: 201,
src: 'http://localhost/galerie/albums/'+filepath+filename
}

});

文件路径和文件名是我想用 src 设置的变量 > 这些来自 Controller 。

请帮助我找到解决方案。谢谢。

最佳答案

试试这个,

Ext.define('MyApp.view.MyImage', {
extend: 'Ext.Img',
alias: 'widget.myimage',

config: {
height: 201,
id: 'galimage',
width: 201,
src: 'http://localhost/galerie/albums/'+filepath+filename
}
});

然后你就可以像这样在你想要的时候动态地设置你的图像了,

Ext.getCmp('galimage').setSrc("resources/Images/Img_Food_New.png"); // in setSrc you can give path of your image

OR

Ext.getCmp('galimage').setHtml('<img src="resources/Images/Img_Food_New.png" height="100%" width="100%"/>'); // in src you can give path of your image

希望对您有所帮助。

关于sencha-touch-2 - 如何在 Sencha Architect 中动态设置 Ext.Img ->"src"的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15702635/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com