问题描述
在本地运行正常时,我在生产中遇到以下错误。关键是我要从后端获取pdf,并使用iframe将其显示在组件内部。在本地时,在我遇到这些问题时,它显示得很好...
拒绝使用框架“ blob:example.com / ...”,因为它违反了以下内容安全政策指令:“ default-src'self'https://www.googletagmanager.com https://www.google-analytics.com。请注意,'frame- src”未明确设置,因此将“ default-src”用作后备广告。
不允许加载本地资源:blob:example.com
这是我的代码:
<iframe
width="100%"
height="100%"
type="application/pdf"
:src="file"
/>
axios(`${apiURL}/pdf`,{
method: 'GET',responseType: 'blob' //Force to receive data in a Blob Format
})
.then(response => {
//Create a Blob from the PDF Stream
const file = new Blob(
[response.data],{type: 'application/pdf'});
//Build a URL from the file
this.file = URL.createObjectURL(file);
})
.catch(error => {
console.log(error);
});
该如何解决?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)