File tree Expand file tree Collapse file tree 2 files changed +7
-10
lines changed Expand file tree Collapse file tree 2 files changed +7
-10
lines changed Original file line number Diff line number Diff line change 1- <!--
2- <div>
3- 带压缩的上传
4- <upload-image v-model="imageUrl" :fileSize="512" />
5- 已上传文件 {{ imageUrl }}
6- </div>
7- -->
81
92<template >
103 <div >
1710 :before-upload =" beforeImageUpload"
1811 :multiple =" false"
1912 >
20- <img v-if =" imageUrl" :src =" imageUrl " class =" image" >
13+ <img v-if =" imageUrl" :src =" showImageUrl " class =" image" >
2114 <i v-else class =" el-icon-plus image-uploader-icon" />
2215 </el-upload >
2316 </div >
@@ -53,7 +46,10 @@ export default {
5346 }
5447 },
5548 computed: {
56- ... mapGetters (' user' , [' userInfo' , ' token' ])
49+ ... mapGetters (' user' , [' userInfo' , ' token' ]),
50+ showImageUrl () {
51+ return (this .imageUrl && this .imageUrl .slice (0 , 4 ) !== ' http' ) ? path + this .imageUrl : this .imageUrl
52+ }
5753 },
5854 methods: {
5955 beforeImageUpload (file ) {
@@ -70,6 +66,7 @@ export default {
7066 const { data } = res
7167 if (data .file ) {
7268 this .$emit (' change' , data .file .url )
69+ this .$emit (' on-success' )
7370 }
7471 }
7572 }
Original file line number Diff line number Diff line change 1717 </el-col >
1818 <el-col :span =" 12" >
1919 带压缩的上传, (512(k)为压缩限制)
20- <upload-image v-model =" imageUrl" :file-size =" 512" :max-w-h =" 1080" />
20+ <upload-image v-model =" imageUrl" :file-size =" 512" :max-w-h =" 1080" @on-success = " getTableData " />
2121 已上传文件 {{ imageUrl }}
2222 </el-col >
2323 </el-row >
You can’t perform that action at this time.
0 commit comments