1、下载pdf.js,http://mozilla.github.io/pdf.js/getting_started/
2、将下载的文件移至public文件夹中
3、使用,接口返回值类型为 blob
downloadDatasheet(e, part) { if (part.military) { return this.$message.warning(this.$t("part_page.alert.enable")); } downDataSheet(part.name).then(res => {
let blob = new Blob([res.data], {type: 'application/pdf;charset=UTF-8'}); var href = window.URL.createObjectURL(blob); //创建下载的链接 window.open("/pdfjs/web/viewer.html?file="+href) }) },