提交 63af7ee4 编写于 作者: Mr.奇淼('s avatar Mr.奇淼(

修改上传图片相关bug

上级 0457a95e
<!--
<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')
}
}
}
......
......@@ -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>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册