瀏覽代碼

打印图片

natasha 2 周之前
父節點
當前提交
6135009fd1
共有 2 個文件被更改,包括 37 次插入13 次删除
  1. 36 12
      src/views/bookShelf/components/PrintModel.vue
  2. 1 1
      src/views/bookShelf/index.vue

+ 36 - 12
src/views/bookShelf/components/PrintModel.vue

@@ -182,16 +182,24 @@
                     :key="indexI"
                     :key="indexI"
                     style="text-align: center"
                     style="text-align: center"
                   >
                   >
-                    <el-image
+                    <img
+                      @load="handleImageLoad($event, itemI)"
+                      :style="{
+                        width: itemI.width,
+                        height: itemI.height,
+                      }"
+                      :src="itemI.src"
+                    />
+                    <!-- <el-image
                       :src="itemI.src"
                       :src="itemI.src"
                       fit="contain"
                       fit="contain"
                       :style="{
                       :style="{
-                        width: itemI.width + 'px',
-                        height: itemI.height + 'px',
+                        width: itemI.width,
+                        height: itemI.height,
                       }"
                       }"
                       :preview-src-list="[itemI.src]"
                       :preview-src-list="[itemI.src]"
                       @load="handleImageLoad($event, itemI)"
                       @load="handleImageLoad($event, itemI)"
-                    ></el-image>
+                    ></el-image> -->
                   </figure>
                   </figure>
                 </template>
                 </template>
               </div>
               </div>
@@ -731,16 +739,24 @@
                   :key="indexI"
                   :key="indexI"
                   style="text-align: center"
                   style="text-align: center"
                 >
                 >
-                  <el-image
+                  <img
+                    @load="handleImageLoad($event, itemI)"
+                    :style="{
+                      width: itemI.width,
+                      height: itemI.height,
+                    }"
+                    :src="itemI.src"
+                  />
+                  <!-- <el-image
                     :src="itemI.src"
                     :src="itemI.src"
                     fit="contain"
                     fit="contain"
                     :style="{
                     :style="{
-                      width: itemI.width + 'px',
-                      height: itemI.height + 'px',
+                      width: itemI.width,
+                      height: itemI.height,
                     }"
                     }"
                     :preview-src-list="[itemI.src]"
                     :preview-src-list="[itemI.src]"
-                    @load="handleImageLoad($event, itemI)"
-                  ></el-image>
+                    
+                  ></el-image> -->
                 </figure>
                 </figure>
               </template>
               </template>
             </div>
             </div>
@@ -1773,12 +1789,17 @@ export default {
       });
       });
     },
     },
     handleImageLoad(event, item) {
     handleImageLoad(event, item) {
-      if (!item.width) {
-        item.width = event.target.naturalWidth;
+      if (!item.width || item.width > 870) {
+        item.width =
+          event.target.naturalWidth > 870
+            ? 870 + "px"
+            : event.target.naturalWidth + "px";
       }
       }
       if (!item.height) {
       if (!item.height) {
-        item.height = event.target.naturalHeight;
+        item.height =
+          item.width === "870px" ? "" : event.target.naturalHeight + "px";
       }
       }
+      this.$forceUpdate();
     },
     },
   },
   },
   mounted() {
   mounted() {
@@ -2205,6 +2226,9 @@ export default {
 :deep .image img {
 :deep .image img {
   max-width: 100%;
   max-width: 100%;
 }
 }
+:deep figure {
+  margin: 1em 0;
+}
 </style>
 </style>
 <style lang="scss">
 <style lang="scss">
 .item-page {
 .item-page {

+ 1 - 1
src/views/bookShelf/index.vue

@@ -560,7 +560,7 @@ export default {
   },
   },
   //生命周期 - 创建完成(可以访问当前this实例)
   //生命周期 - 创建完成(可以访问当前this实例)
   created() {
   created() {
-    console.log("2025-07-11");
+    console.log("2025-07-11-1");
     if (this.userMessage) {
     if (this.userMessage) {
       this.getNumber();
       this.getNumber();
       this.getList();
       this.getList();