我正在尝试通过Phonegap Build应用程序中的jquery动态更改src,像这样
$('#photo_profile').attr('src', fullPath).one("load", function(evt) {
console.log("load");
}).each(function() {
if(this.complete) $(this).load();
});
但是,每次更改src时,在显示“加载”日志时,img不会刷新。
fullPath
就像 file:///storage/emulated/0/MyAppFolder/Media/Profile%20Photos/profile.jpg
这是一条有效路径,就好像我杀死了该应用程序,然后重新启动它一样,显示了正确的图像。
难道我做错了什么?谢谢
听起来像是缓存问题。尝试使用一些随机参数阻止它:
$('#photo_profile').prop('src', fullPath + '?' + Math.random())
也是src
一个属性,因此使用prop
代替是有意义的attr
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句