IOS文件下载不起作用



我在下载IOS文件时遇到问题。我试图让用户在单击链接时下载文件。我创建了一个 blob 并单击链接。

它在台式机上工作正常,但在移动设备上无法正常工作...

            let blob = new Blob([success], { type: success.type });
        if (window.navigator && window.navigator.msSaveOrOpenBlob) {
          window.navigator.msSaveOrOpenBlob(blob, dd.filename);
        } else {
          let a  = document.createElement('a');
          let url = URL.createObjectURL(blob);
          a.href = url;
          a.download = dd.filename;
          document.body.appendChild(a);
          a.click();
          document.body.removeChild(a);
          this.flashService.success('Dernières consultations', 'Ce document a été téléchargé');
          this.downloaded.emit(this.document);
        }

谢谢

我终于找到了答案。

{ type: success.type }

我在这个变量中的类型错误,这就是原因。移动导航器无法识别文件类型

最新更新