移动端,点击a标签链接的pdf报错 Resource interpreted as Document but transferred with MIME type application/pdf

时间:2023-03-09 18:17:10
移动端,点击a标签链接的pdf报错    Resource interpreted as Document but transferred with MIME type application/pdf

源码:

<a href="11.pdf" class="actcont_a fl report_a" style="display: block;">
</a>

解决方案:

<a href="11.pdf" class="actcont_a fl report_a" style="display: block;"  download='11">
</a>

原因:

因为浏览器不知道对这个文件干嘛,所以报错,当指定了文件要干嘛就不会报错了

新页面不用报错,直接把这个文件下载就好了(加target)
当前页面打开的不能直接下载(不加target)
必须要有download属性才会下载