修改上传图片相关bug

This commit is contained in:
蒋吉兆
2021-07-10 12:08:28 +08:00
parent 44e7b643f9
commit 3271542a9b
2 changed files with 7 additions and 10 deletions

View File

@@ -1,10 +1,3 @@
<!--
<div>
带压缩的上传
<upload-image v-model="imageUrl" :fileSize="512" />
已上传文件 {{ imageUrl }}
</div>
-->
<template>
<div>
@@ -17,7 +10,7 @@
:before-upload="beforeImageUpload"
:multiple="false"
>
<img v-if="imageUrl" :src="imageUrl" class="image">
<img v-if="imageUrl" :src="showImageUrl" class="image">
<i v-else class="el-icon-plus image-uploader-icon" />
</el-upload>
</div>
@@ -53,7 +46,10 @@ export default {
}
},
computed: {
...mapGetters('user', ['userInfo', 'token'])
...mapGetters('user', ['userInfo', 'token']),
showImageUrl() {
return (this.imageUrl && this.imageUrl.slice(0, 4) !== 'http') ? path + this.imageUrl : this.imageUrl
}
},
methods: {
beforeImageUpload(file) {
@@ -70,6 +66,7 @@ export default {
const { data } = res
if (data.file) {
this.$emit('change', data.file.url)
this.$emit('on-success')
}
}
}