1 个回答
details: Error: The `Array.prototype` contains unexpected enumerable properties: max, min, mean, rep, pip; thus breaking e.g. `for...in` iteration of `Array`s.
​
message: The `Array.prototype` contains unexpected enumerable properties: max, min, mean, rep, pip; thus breaking e.g. `for...in` iteration of `Array`s.

name: "UnknownErrorException"

pdf.js在其他项目使用过,但在新项目中使用,却报了这个问题,我在网上寻找解决方案,发现有人遇到过类似的问题 github pdf.js 异常报错。

在pdf.js的 github issue上,我找到了问题原因,就像报错信息提示的一样,存在js库对 Array.prototype 进行了扩展,pdf.js认为这是在错误地扩展对象和/或数组,并且以一种破坏例如for…的方式进行交互

解决方法

在控制台上打印 Array.prototype,看看 Array.prototype是不是被扩展,出现了下面的这些方法:max, min, mean, rep, pip,或是其他的方法,其他方法也是一样。
pdf.js认为以上的这些方法:这是在错误地扩展对象和/或数组,并且以一种破坏例如for…的方式进行交互。

将Array.prototype扩展方法移除,只需要找进行Array.prototype扩展的第三方库,并且在代码中移除它就可以,这样,问题就被解决了。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题