在Microsoft Edge中不允许加载blob pdf资源。

7

这个应用程序用于从数据库中收集信息并生成一个pdf文件。

this.reportsService.getTelerikReport({ reportId: this.selectReportId, startDate: this.startDate, endDate: this.endDate, ReportItems: listCheckItems})
        .then(response => {
            this.fileLoading = false;
            var file = new Blob([response], { type: "application/pdf" });
            this.fileUrl = this.$sce.trustAsResourceUrl(URL.createObjectURL(file));
            this.isReportGenerated = true;

我在 Microsoft Edge 浏览器控制台中收到了一个错误。许多人说这是 Edge 浏览器的安全问题。

有人能为我提供帮助吗?

1个回答

10

旧的解决方案对于微软浏览器仍然适用:

if (window.navigator && window.navigator.msSaveOrOpenBlob) {
    window.navigator.msSaveOrOpenBlob(blob);  
}
else {
    var objectUrl = URL.createObjectURL(blob);
    window.open(objectUrl);  
}

源自这里


1
在最新版本的IE11中,该属性“msSaveOrOpenBlob”已经不存在了。 - mirik

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接