natasha преди 2 седмици
родител
ревизия
d65f2b8a3c
променени са 3 файла, в които са добавени 43 реда и са изтрити 4 реда
  1. 12 0
      src/views/bookShelf/articleDetail.vue
  2. 1 0
      src/views/bookShelf/components/NormalModel.vue
  3. 30 4
      src/views/bookShelf/components/PrintModel.vue

+ 12 - 0
src/views/bookShelf/articleDetail.vue

@@ -1424,6 +1424,18 @@ export default {
                               items.indexOf("width: ") + indexW + 7
                             )
                           : null,
+                      height:
+                        items.indexOf('height="') > -1
+                          ? items.substring(
+                              items.indexOf('height="') + 8,
+                              items.indexOf('height="') + indexH + 8
+                            )
+                          : items.indexOf("height: ") > -1
+                          ? items.substring(
+                              items.indexOf("height: ") + 8,
+                              items.indexOf('height="') + indexH + 8
+                            )
+                          : null,
                     };
                     imgArr.push(imgobj);
                   }

+ 1 - 0
src/views/bookShelf/components/NormalModel.vue

@@ -815,6 +815,7 @@ export default {
   font-weight: 400;
   line-height: 32px;
   color: #2f3742;
+  overflow-x: hidden;
   img {
     max-width: 100%;
   }

+ 30 - 4
src/views/bookShelf/components/PrintModel.vue

@@ -183,11 +183,14 @@
                     style="text-align: center"
                   >
                     <el-image
-                      :width="itemI.width"
-                      :height="itemI.height"
                       :src="itemI.src"
                       fit="contain"
+                      :style="{
+                        width: itemI.width + 'px',
+                        height: itemI.height + 'px',
+                      }"
                       :preview-src-list="[itemI.src]"
+                      @load="handleImageLoad($event, itemI)"
                     ></el-image>
                   </figure>
                 </template>
@@ -729,11 +732,14 @@
                   style="text-align: center"
                 >
                   <el-image
-                    :width="itemI.width"
-                    :height="itemI.height"
                     :src="itemI.src"
                     fit="contain"
+                    :style="{
+                      width: itemI.width + 'px',
+                      height: itemI.height + 'px',
+                    }"
                     :preview-src-list="[itemI.src]"
+                    @load="handleImageLoad($event, itemI)"
                   ></el-image>
                 </figure>
               </template>
@@ -1634,6 +1640,18 @@ export default {
                                 items.indexOf("width: ") + indexW + 7
                               )
                             : null,
+                        height:
+                          items.indexOf('height="') > -1
+                            ? items.substring(
+                                items.indexOf('height="') + 8,
+                                items.indexOf('height="') + indexH + 8
+                              )
+                            : items.indexOf("height: ") > -1
+                            ? items.substring(
+                                items.indexOf("height: ") + 8,
+                                items.indexOf('height="') + indexH + 8
+                              )
+                            : null,
                       };
                       imgArr.push(imgobj);
                     }
@@ -1754,6 +1772,14 @@ export default {
         }
       });
     },
+    handleImageLoad(event, item) {
+      if (!item.width) {
+        item.width = event.target.naturalWidth;
+      }
+      if (!item.height) {
+        item.height = event.target.naturalHeight;
+      }
+    },
   },
   mounted() {
     if (this.articleInfo) {