将arraybuffer转换为string:超出了最大调用堆栈大小

这是我的代码行。

var xhr = new XMLHttpRequest(); xhr.open('GET',window.location.href, true); xhr.responseType = "arraybuffer"; xhr.onload = function(event) { debugger; console.log(" coverting array buffer to string "); alert(String.fromCharCode.apply(null, new Uint8Array(this.response))); }; xhr.send(); 

该请求正在制作一个大约3 MB的pdfurl。 阅读几个线程有相同的错误,告诉必须有一些递归调用,但我没有在这里看到任何递归调用。 有帮助吗?

该错误是由函数参数数量的限制引起的。 请参阅“RangeError:超出最大调用堆栈大小”为什么?

而不是String.fromCharCode.apply() ,使用例如TextEncoder 。 请参阅Jint中的Uint8Array字符串