Sai*_* SB 8 mobile-safari angular
我的Angular应用程序具有pdf下载选项。当我在Iphone(IOS 12)Safari浏览器中运行应用程序时,收到以下错误消息,如图所示
我该如何解决?

小智 10
如果您以编程方式将 ancor 标记注入 DOM 作为您的解决方案,请确保不要过早清除它。
对我来说 100ms 工作正常,但由于它是不可见的,我选择了 1 秒延迟清除 DOM。
示例代码:
this.fileApi.download(<your args>).subscribe((data: Blob) => {
const url = window.URL.createObjectURL(data);
const a = document.createElement('a');
a.style.display = 'none';
a.href = url;
// the filename you want
a.download = <your filename>;
document.body.appendChild(a);
a.click();
setTimeout(() => {
window.URL.revokeObjectURL(url);
document.body.removeChild(a);
}, 1000);
})
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
577 次 |
| 最近记录: |