哎,需求总是最难伺候的,优化了几次都不满意,但是没办法,只能想办法.这是最终版的PDF,使用了 pdfh5 插件,别说,还挺好用的,强烈推荐!
### 模板
<template>
<div class="page">
<MyHeader pageTitle="PDF预览" :backPre="true" :downMenu="false"/>
<div class="content">
<div id="demo"</div>
</div>
</template>
### JS代码
<script>
import axios from "axios";
import Pdfh5 from "pdfh5";
import "pdfh5/css/pdfh5.css";
export default{
name:"DownloadServiceManul",
data(){
return {
pdfh5:null
};
},
props:{
propsData:[Object]
},
methods:{
initPDF(){
const {fileId} = this.propsData;
this.pdfh5 = new Pdfh5("#demo",{
pdfurl:axios.defaults.baseURL + `/downloadServiceManul?fileId=${fileId}&v=${Date.now()}`,
renderType:"canvas",
pageNum:true,
lazy:true,
scrollEnable:true,
maxZoom:2,
scale:1,
zoomEnable:true,
cMapUrl:"/cmaps/",
withCredentials:true
});
}
},
mounted(){
this.initPDF();
}
}
</script>