Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/433.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 无法将blob作为文本加载到js上_Javascript_Blob_Filereader - Fatal编程技术网

Javascript 无法将blob作为文本加载到js上

Javascript 无法将blob作为文本加载到js上,javascript,blob,filereader,Javascript,Blob,Filereader,所以,我在一个zip中有一个作为txt的blob。我可以访问txt文件,但无法打开它。我已经通过npm安装了FileReader,并尝试了我在stackoverflowhttps://stackoverflow.com/questions/23024460/javascript-i-created-a-blob-from-a-string-how-do-i-get-the-string-back-out,但我没有收到任何警报或日志 convertInText = (blob) => {

所以,我在一个zip中有一个作为txt的blob。我可以访问txt文件,但无法打开它。我已经通过npm安装了FileReader,并尝试了我在stackoverflow
https://stackoverflow.com/questions/23024460/javascript-i-created-a-blob-from-a-string-how-do-i-get-the-string-back-out
,但我没有收到任何警报或日志

convertInText = (blob) => {

        let reader = new FileReader();
        reader.readAsText(blob, "ANSI");
        reader.onloadend = function(e) {
            console.log(reader.result);
        };

    };

还导入了FileReader,但没有结果。

这不是有效的代码示例。blob定义在哪里,没有指向您在堆栈上尝试的内容的链接,我看不出您希望在日志中看到什么?日志语句在哪里。。这里还需要一些示例。@DylanWright这是我从堆栈中使用的,用链接和方法更新。Alert/console.log,只是告诉您我两个都试过了。两者兼得的目的是什么?我想这很明显会出现在警报出现的地方。你说的“我是由NPM FileReader安装的”是什么意思?当您查看列出的堆栈问题时,您提供了一个指向MDN FileReader API的链接。。不是npm包。答案的注释中还有一个JSFIDLE,带有一个工作样本。如果您仍然有问题,您的文件可能具有某种读/写权限,或者可能被其他进程打开。没问题,祝您好运