我正在使用jQuery + jQuery Mobile + Cordova用于手机应用,需要动态更改图片。 当然,这不是一个挑战,我只是使用
$('myElement').attr('src', 'img/myImage' + someIndex + '.png');但每当执行此操作时,我的LogCat中会出现一个Unknown Chromium Error: -6 。 图像仍然显示得很好,但我想知道这是从哪里来的? 评论这一行会使错误消失,因此必须如此。
I'm using jQuery+jQuery Mobile+Cordova for a mobile phone app and need to dynamically change a picture. Of course this isn't a challenge and I simply use
$('myElement').attr('src', 'img/myImage' + someIndex + '.png');But whenever this gets executed, I get an Unknown Chromium Error: -6 in my LogCat. The image(s) are still being displayed just fine, but I'm wondering where this is coming from? Commenting this line out makes the error go away, so it has to be this.
最满意答案
由于URL格式错误,最有可能发生Unknown Chromium Error: -6错误。
您可以尝试将代码更改为:
$('#myElement').attr('src', 'file:///android_asset/img/myImage' + someIndex + '.png');前缀file:///android_asset/可用于从当前应用程序的assets文件夹加载内容。
I just happened to realize what the problem was. I was displaying, say, n images, but I only showed k < n of them (i.e. 3 of 5 total). The ones not being displayed accidentally were set to have a non-existing image, causing the error. Since they weren't being displayed, there was no visible problem.
更多推荐
发布评论