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

Ste*_*fan 6 javascript microsoft-edge

此应用程序用于从数据库收集信息并从中生成.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;
Run Code Online (Sandbox Code Playgroud)

我只在Microsoft Edge控制台中收到错误.很多人说这是Edge浏览器的安全问题.

有人能为我提供帮助吗?

小智 7

适用于Microsoft浏览器的旧解决方案仍适用:

if (window.navigator && window.navigator.msSaveOrOpenBlob) {
    window.navigator.msSaveOrOpenBlob(blob);  
}
else {
    var objectUrl = URL.createObjectURL(blob);
    window.open(objectUrl);  
}
Run Code Online (Sandbox Code Playgroud)

来源于此