之前記錄過一篇查看pdf的npm方法,但是在移動端去查看,翻頁去加載的時候會出現卡頓,發現pdfh5用戶體驗會更加友好。推薦一下:
安裝依賴包: npm install pdfh5
import Pdfh5 from "pdfh5";
export default {
name: 'App',
data() {
return {
pdfh5: null
};
},
mounted() {
//實例化
this.pdf = new Pdf("#pdf", {
pdfurl: "XXXXXXXXXXXXX/test.pdf"
});
//監聽完成事件
this.pdf.on("complete", function (status, msg, time) {
console.log("狀態:" + status + ",信息:" + msg + ",耗時:" + time + "毫秒,總頁數:" + this.totalNum)
})
}
}
@import "pdfh5/css/pdfh5.css";
*{
padding: 0;
margin: 0;
}
html,body,#app {
width: 100%;
height: 100%;
}