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