浏览代码

展示图片

yuanyiming 2 年之前
父节点
当前提交
4ca73ff464
共有 1 个文件被更改,包括 19 次插入17 次删除
  1. 19 17
      src/views/firm.vue

+ 19 - 17
src/views/firm.vue

@@ -123,7 +123,9 @@
       <div class="showFileArea">
         <!-- <vpdf v-if="/^\s*$/g.test(showFileUrl)&&showFileUrl.split('.')[showFileUrl.split('.').length-1]=='pdf'" :pdfUrl="showFileUrl"></vpdf> -->
         <vword v-if="showFileType == 0" :pdfUrl="showFileUrl"></vword>
-        <vpdf v-else :pdfUrl="showFileUrl"></vpdf>
+        <!-- <vpdf v-else :pdfUrl="showFileUrl"></vpdf> -->
+        <vpdf  v-if="showFileType == 1" :pdfUrl="showFileUrl"></vpdf>
+        <img v-if="showFileType == 2" :src="showFileUrl" style="width: auto;height: auto;max-width: 100%;max-height: 100%;" alt="">
       </div>
     </el-dialog>
     <!-- 展示文档结束 -->
@@ -161,22 +163,22 @@ export default {
   methods: {
     //展示文件
     checkFile(url) {
-      if (
-        url.split(".")[url.split(".").length - 1].toLocaleUpperCase() == "PDF"
-      ) {
-        this.showFileUrl = url;
-        this.showFileType = 1;
-      } else if(
-        url.split(".")[url.split(".").length - 1].toLocaleUpperCase() == ("PNG" || 'JPG')
-      )
-      {
-        this.showFileUrl = url;
-      }
-      else {
-        console.log(url.split(".")[url.split(".").length - 1].toLocaleUpperCase());
-
-        this.showFileUrl =
-          "https://view.officeapps.live.com/op/view.aspx?src=" + url;
+    
+      if (url.split(".")[url.split(".").length - 1].toLocaleUpperCase() == "PDF") {
+          this.showFileUrl = url;
+          this.showFileType = 1;
+        }
+      // else {
+      //   this.showFileUrl =
+      //     "https://view.officeapps.live.com/op/view.aspx?src=" + url;
+      //     this.showFileType = 0;
+      // }
+      if (url.split(".")[url.split(".").length - 1].toLocaleUpperCase() == ('PNG' || 'JPG')) {
+        console.log(1111);
+          this.showFileUrl = url;
+          this.showFileType = 2;
+      }else{
+          this.showFileUrl ="https://view.officeapps.live.com/op/view.aspx?src=" + url;
           this.showFileType = 0;
       }
       this.showFile = true;