JavaScript readAsDataurl不是一个函数 [英] JavaScript readAsDataurl is not a function
问题描述
在Gecko / Firefox中我收到错误消息:
In Gecko/Firefox I got the error message:
TypeError:fr.readAsDataurl不是函数
TypeError: fr.readAsDataurl is not a function
使用以下JavaScript:
Using the following JavaScript:
var fr = new FileReader();
fr.readAsDataURL(files[i]);
推荐答案
事实证明,Mozilla的某人创建了弃用的方法 readAsDataurl
使用不正确的字母大小写,因为JavaScript区分大小写,我只需使用 readAsDataURL
方法(大写网址) :
As it turns out someone at Mozilla created the deprecated method readAsDataurl
with the improper letter casing and since JavaScript is case sensitive I simply had to use the readAsDataURL
method (uppercase URL):
if (fr.readAsDataURL) {fr.readAsDataURL(files[i]);}
else if (fr.readAsDataurl) {fr.readAsDataurl(files[i]);}
注意标准/ 首先检测到正确的套管方法。如果您希望代码尽快运行,随着标准支持的改进,性能会随着时间的推移而提高。
Note that the standard/proper casing method is detected first. If you want your code to work as quickly as possible performance will improve over time as standards support improves.
这篇关于JavaScript readAsDataurl不是一个函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!