Browse Source

解决详情页不显示icon

Limengbo 6 years ago
parent
commit
1bc13bbb63
1 changed files with 6 additions and 1 deletions
  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`)
+      }
     }
   }
 }