我正在使用以下函数在 Office 365 应用程序内下载附件文件(作为二进制数据):
var saveByteArray = function (data, name) {
var a = document.createElement("a");
document.body.appendChild(a);
a.style = "display: none";
var blob = new Blob(data, { type: "octet/stream" }),
url = window.URL.createObjectURL(blob);
a.href = url;
a.download = name;
a.click();
window.URL.revokeObjectURL(url);
};
它在 Chrome 浏览器中运行成功,但当我通过 Outlook 桌面客户端打开它时,出现以下错误:
Error TypeError: Assignment to read-only properties is not allowed in strict mode
执行此行时发生错误:
access a.style = "display: none";
此实现有任何替代解决方案吗?
最佳答案
关于javascript - 如何在严格模式下将附件下载为二进制数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28317513/