动态变化的图像会导致铬误差(Dynamically changing picture causes chromium error)

编程入门 行业动态 更新时间:2024-10-27 14:19:20
动态变化的图像会导致铬误差(Dynamically changing picture causes chromium error)

我正在使用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.

更多推荐

本文发布于:2023-08-07 20:26:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1465648.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:误差   图像   动态   Dynamically   error

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!