New file |
| | |
| | | <template> |
| | | <div class="pdf-container"> |
| | | <iframe :src="fileUrl" width="100%" height="100%"></iframe> |
| | | </div> |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { ref, onMounted } from 'vue'; |
| | | |
| | | const props = defineProps({ |
| | | pdfUrl: { |
| | | type: String, |
| | | required: true |
| | | } |
| | | }); |
| | | const viewerUrl = '/pdfjs/web/viewer.html?file='; // pdfjs文件地址 |
| | | |
| | | const fileUrl = ref(''); |
| | | |
| | | |
| | | const renderPDF = () => { |
| | | fileUrl.value = viewerUrl + encodeURIComponent(props.pdfUrl); |
| | | }; |
| | | |
| | | onMounted(() => { |
| | | renderPDF(); |
| | | }) |
| | | |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | .pdf-container { |
| | | width: 100%; |
| | | height: 100%; |
| | | |
| | | .pdf-canvas { |
| | | width: 100%; |
| | | height: 100%; |
| | | } |
| | | } |
| | | </style> |