Bläddra i källkod

重新配置成iframe

pm 8 månader sedan
förälder
incheckning
1d7f17a1b4
2 ändrade filer med 16 tillägg och 27 borttagningar
  1. 0 1
      package.json
  2. 16 26
      src/views/mes/pdf/Pdf.vue

+ 0 - 1
package.json

@@ -65,7 +65,6 @@
     "vue-cropper": "0.5.5",
     "vue-form-generator": "^2.3.4",
     "vue-meta": "2.4.0",
-    "vue-pdf": "^4.3.0",
     "vue-plugin-hiprint": "^0.0.54-fix",
     "vue-router": "3.4.9",
     "vuedraggable": "2.24.3",

+ 16 - 26
src/views/mes/pdf/Pdf.vue

@@ -1,44 +1,34 @@
-<!-- PdfViewer.vue -->
 <template>
   <div>
-    <pdf
-      v-for="i in numPages"
-      :key="i"
+    <!-- 使用 iframe 加载 PDF 文件 -->
+    <iframe
       :src="file"
-      :page="i"
-      style="display: inline-block; width: 100%;"
-    ></pdf>
+      width="100%"
+      height="800px"
+      style="border: none;"
+    ></iframe>
   </div>
 </template>
 
 <script>
-import pdf from 'vue-pdf'
-
 export default {
-  components: {
-    pdf
-  },
   data() {
     return {
-      file: null,
-      numPages: undefined
-    }
+      file: null, // PDF 文件的 URL
+    };
   },
   created() {
-    this.file = this.$route.query.file
-    this.loadPdf()
+    // 从路由 query 参数中获取 PDF 文件 URL
+    this.file = this.$route.query.file;
   },
-  methods: {
-    loadPdf() {
-      const loadingTask = pdf.createLoadingTask(this.file)
-      loadingTask.promise.then(pdf => {
-        this.numPages = pdf.numPages
-      })
-    }
-  }
-}
+};
 </script>
 
 <style scoped>
 /* 添加一些样式以适应你的需求 */
+iframe {
+  width: 100%;
+  height: 100vh; /* 使 iframe 占满整个视口高度 */
+  border: none; /* 去除 iframe 的边框 */
+}
 </style>