소스 검색

解决详情页不显示icon

Limengbo 6 년 전
부모
커밋
1bc13bbb63
1개의 변경된 파일6개의 추가작업 그리고 1개의 파일을 삭제
  1. 6 1
      src/views/fileDetail/index.vue

+ 6 - 1
src/views/fileDetail/index.vue

@@ -12,7 +12,7 @@
       <el-table-column
         :label="title">
         <template slot-scope="scope">
-          <img :src="(scope.row.fileType == 'png' || scope.row.fileType == 'jpg') ? scope.row.path : '../../../static/fileimg/'+scope.row.fileType+'.png'" alt="file_icon" style="vertical-align: middle; margin-right: 10px">
+          <img :src="(scope.row.fileType == 'png' || scope.row.fileType == 'jpg') ? scope.row.path : imgUrl(scope.row)" alt="file_icon" style="vertical-align: middle; margin-right: 10px">
           <span>{{ scope.row.fileName }}</span>
         </template>
       </el-table-column>
@@ -79,6 +79,11 @@ export default {
       document.body.appendChild(link)
       link.click()
       addViewLog(row.id, row.taskId)
+    },
+    imgUrl(url) {
+      if (url.fileType) {
+        return require(`@/assets/fileimg/${url.fileType}.png`)
+      }
     }
   }
 }