Commit bcceac5df2a26160c576c93bba819f35afcbb584
1 parent
38614abe
v3.8.1 预览组件支持多图显示
Showing
1 changed file
with
29 additions
and
12 deletions
yudao-ui-admin/src/components/ImagePreview/index.vue
| 1 | 1 | <template> |
| 2 | - <el-image :src="`${realSrc}`" fit="cover" :style="`width:${realWidth};height:${realHeight};`" :preview-src-list="[`${realSrc}`]"> | |
| 2 | + <el-image | |
| 3 | + :src="`${realSrc}`" | |
| 4 | + fit="cover" | |
| 5 | + :style="`width:${realWidth};height:${realHeight};`" | |
| 6 | + :preview-src-list="realSrcList" | |
| 7 | + > | |
| 3 | 8 | <div slot="error" class="image-slot"> |
| 4 | 9 | <i class="el-icon-picture-outline"></i> |
| 5 | 10 | </div> |
| ... | ... | @@ -7,10 +12,10 @@ |
| 7 | 12 | </template> |
| 8 | 13 | |
| 9 | 14 | <script> |
| 10 | -import { isExternal } from '@/utils/validate' | |
| 15 | +import { isExternal } from "@/utils/validate"; | |
| 11 | 16 | |
| 12 | 17 | export default { |
| 13 | - name: 'ImagePreview', | |
| 18 | + name: "ImagePreview", | |
| 14 | 19 | props: { |
| 15 | 20 | src: { |
| 16 | 21 | type: String, |
| ... | ... | @@ -18,28 +23,40 @@ export default { |
| 18 | 23 | }, |
| 19 | 24 | width: { |
| 20 | 25 | type: [Number, String], |
| 21 | - default: '' | |
| 26 | + default: "" | |
| 22 | 27 | }, |
| 23 | 28 | height: { |
| 24 | 29 | type: [Number, String], |
| 25 | - default: '' | |
| 30 | + default: "" | |
| 26 | 31 | } |
| 27 | 32 | }, |
| 28 | 33 | computed: { |
| 29 | 34 | realSrc() { |
| 30 | - if (isExternal(this.src)) { | |
| 31 | - return this.src | |
| 35 | + let real_src = this.src.split(",")[0]; | |
| 36 | + if (isExternal(real_src)) { | |
| 37 | + return real_src; | |
| 32 | 38 | } |
| 33 | - return process.env.VUE_APP_BASE_API + this.src | |
| 39 | + return process.env.VUE_APP_BASE_API + real_src; | |
| 40 | + }, | |
| 41 | + realSrcList() { | |
| 42 | + let real_src_list = this.src.split(","); | |
| 43 | + let srcList = []; | |
| 44 | + real_src_list.forEach(item => { | |
| 45 | + if (isExternal(item)) { | |
| 46 | + return srcList.push(item); | |
| 47 | + } | |
| 48 | + return srcList.push(process.env.VUE_APP_BASE_API + item); | |
| 49 | + }); | |
| 50 | + return srcList; | |
| 34 | 51 | }, |
| 35 | 52 | realWidth() { |
| 36 | - return typeof this.width == 'string' ? this.width : `${this.width}px` | |
| 53 | + return typeof this.width == "string" ? this.width : `${this.width}px`; | |
| 37 | 54 | }, |
| 38 | 55 | realHeight() { |
| 39 | - return typeof this.height == 'string' ? this.height : `${this.height}px` | |
| 56 | + return typeof this.height == "string" ? this.height : `${this.height}px`; | |
| 40 | 57 | } |
| 41 | - } | |
| 42 | -} | |
| 58 | + }, | |
| 59 | +}; | |
| 43 | 60 | </script> |
| 44 | 61 | |
| 45 | 62 | <style lang="scss" scoped> | ... | ... |