npm i pdfh5
<template>
<div class="pdfBox">
<div id="previewPdf"></div>
</div>
</template>
<script>
import pdfh5 from 'pdfh5';
import 'pdfh5/css/pdfh5.css'
export default {
name: 'pdfh5',
data () {
return {
pdfh5: null,
}
},
mounted() {
this.openPdf()
},
methods: {
openPdf(url){ //url:PDF文件地址
this.pdfh5 = new pdfh5('#previewPdf', {
pdfurl: 'http://storage.xuetangx.com/public_assets/xuetangx/PDF/PlayerAPI_v1.0.6.pdf'
});
this.pdfh5.on('success', ()=>{
console.log('pdf渲染成功');
});
}
}
}
</script>
<style scoped lang="less">
.pdfBox {
position: relative;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
background: #000;
overflow: hidden;
z-index: 99;
#previewPdf {
height: 100vh;
}
}
</style>
参考地址文章来源:https://www.toymoban.com/news/detail-502526.html
文章来源地址https://www.toymoban.com/news/detail-502526.html
到了这里,关于移动端预览 PDF的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!