Skip to content

Commit 3271542

Browse files
author
蒋吉兆
committed
修改上传图片相关bug
1 parent 44e7b64 commit 3271542

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

web/src/components/upload/image.vue

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
<!--
2-
<div>
3-
带压缩的上传
4-
<upload-image v-model="imageUrl" :fileSize="512" />
5-
已上传文件 {{ imageUrl }}
6-
</div>
7-
-->
81

92
<template>
103
<div>
@@ -17,7 +10,7 @@
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
}

web/src/view/example/upload/upload.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
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>

0 commit comments

Comments
 (0)