angular - 使用被 Chrome 广告块阻止的 Angular 中的 blob 渲染 PDF
问题描述
我的设置如下:
getDocumentPdf(name: string) {
this.pdfService.getPdfFile(name).subscribe((data) => {
const file = new Blob([data], {type:'application/pdf'});
const fileUrl = URL.createObjectURL(file);
window.open(fileUrl);
});
}
和 pdfService 是:
getPdfFile(name: string) {
const url = environment.apiUrl + '/files/';
const httpOpt = {
'responseType': 'arraybuffer' as 'json'
};
return this.http.get<any>(url + name, httpOpt);
}
使用 chrome 时,弹出窗口被阻止。使用隐身可以解决问题,但我希望用户使用标准浏览器访问它。
亲切的问候,
解决方案
推荐阅读
- java - 如何处理删除 DataModel 中的互连对象
- algorithm - 具有快速排序插入、排序删除和查找的数据结构
- vba - 是否可以显示用户表单并执行 .show 方法下方的代码?
- here-api - 了解 FROM_REF_SPEED_LIMIT 和 TO_REF_SPEED_LIMIT 属性
- sql-server - “CREATE TABLE”语句给出错误:数据类型后出现意外“)”
- arrays - 无法使用对象数组设置状态
- postgresql - 触发器是否适用于订单?
- c++ - 没有参数的 C++ 可变参数函数
- excel-formula - 如何从列中检索具有特定值的单元格列表,并将另一列的文本内容显示到另一个工作表中?
- xmlhttprequest - Angular7 + XHook 给出 ERROR TypeError: Illegal invocation