Browse Source

修改上传图片相关bug

main
蒋吉兆 3 years ago
parent
commit
63af7ee4cb
  1. 15
      web/src/components/upload/image.vue
  2. 2
      web/src/view/example/upload/upload.vue

15
web/src/components/upload/image.vue

@ -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')
}
}
}

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

@ -17,7 +17,7 @@
</el-col>
<el-col :span="12">
带压缩的上传, (512(k)为压缩限制)
<upload-image v-model="imageUrl" :file-size="512" :max-w-h="1080" />
<upload-image v-model="imageUrl" :file-size="512" :max-w-h="1080" @on-success="getTableData" />
已上传文件 {{ imageUrl }}
</el-col>
</el-row>

Loading…
Cancel
Save