【问题标题】:IE11 throw Invalid State error with this particular Blob constructionIE11 使用此特定 Blob 构造引发 Invalid State 错误
【发布时间】:2017-02-01 05:07:24
【问题描述】:

我有这段代码可以使用 Blob 保存 excel

//Stream of data as res
var dataView = new DataView(res);
var blob = new Blob([dataView], {type: 'application/vnd.ms-excel'});

但在 IE 中只有第三行会抛出 Invalid State Error,即使在文档中,它也是完全支持的

【问题讨论】:

    标签: javascript internet-explorer blob


    【解决方案1】:

    问题似乎与 IE 有关。 Uint8Array 可以在构造函数中使用。

    要将DataView 转换为等效的Uint8Array

    var u8arr = new Uint8Array(dataView.buffer, dataView.byteOffset, dataView.byteLength);
    

    编写一个函数来替换传递给new Blob 的数组中的所有DataView 对象。或查看the polyfill here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-07-27
      • 1970-01-01
      • 2016-01-13
      • 2021-01-03
      • 1970-01-01
      • 2016-06-16
      相关资源
      最近更新 更多