效果图
实现步骤
代码语言:javascript复制<el-form-item label="产品图" prop="imgurls">
<el-upload
class="avatar-uploader"
action=""
:limit="3"
:http-request="getFile"
:show-file-list="false">
<div v-for="(item, index) in form.imgurls">
<img v-if="item" :src="item" class="avatar">
</div>
<i v-if="form.imgurls.length < 3" class="el-icon-plus avatar-uploader-icon"></i>
</el-upload>
</el-form-item>
limit属性可以限制上传图片的数量
代码语言:javascript复制getFile2(item) {
this.file = item.file
let formData = new FormData();
formData.append("file", this.file);
uploadFile(formData).then(response => {
this.msgSuccess("商品icon图上传成功!");
this.form.icon = response.data.imgShowUrl;
console.log(this.form.icon)
});
},