pdf.vue 738 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <template>
  2. <div class="pdfBox">
  3. <div id="previewPdf"></div>
  4. </div>
  5. </template>
  6. <script>
  7. import pdfh5 from 'pdfh5';
  8. import 'pdfh5/css/pdfh5.css'
  9. export default {
  10. name: 'pdfh5',
  11. data () {
  12. return {
  13. pdfh5: null,
  14. }
  15. },
  16. methods: {
  17. openPdf(url){ //url:PDF文件地址
  18. this.pdfh5 = new pdfh5('#previewPdf', {
  19. pdfurl: url
  20. });
  21. this.pdfh5.on('success', ()=>{
  22. console.log('pdf渲染成功');
  23. });
  24. }
  25. }
  26. }
  27. </script>
  28. <style scoped>
  29. .pdfBox {
  30. position: relative;
  31. top: 0;
  32. left: 0;
  33. width: 100vw;
  34. height: 94vh;
  35. background: #000;
  36. overflow: hidden;
  37. z-index: 99;
  38. box-sizing: border-box;
  39. margin-top: 1.22667rem;
  40. }
  41. #previewPdf {
  42. height: 100%;
  43. }
  44. </style>