vue2 pdf 链接地址打开
1、先下载依赖
"vue-pdf": "^4.3.0",
"pdfh5": "^1.4.0",
"pdfjs-dist": "2.5.207",
3、打开pdf
<template>
<div id="app">
<div id="demo"></div>
</div>
</template>
<script>
import Pdfh5 from "pdfh5";
import "pdfh5/css/pdfh5.css";
export default {
data() {
return {
pdfh5: null,
PDFsrc: this.$route.query.url,
};
},
mounted() {
//实例化
this.pdfh5 = new Pdfh5("#demo", {
pdfurl: this.PDFsrc,
});
//监听完成事件
this.pdfh5.on("complete", function(status, msg, time) {
console.log(
"状态:" +
status +
",信息:" +
msg +
",耗时:" +
time +
"毫秒,总页数:" +
this.totalNum
);
});
},
};
</script>
<style>
* {
padding: 0;
margin: 0;
}
html,
body,
#app {
width: 100%;
height: 100%;
}
#demo {
height: 90vh;
overflow: hidden;
overflow-y: scroll;
}
</style>