<el-upload
@on-change="handleFile"
@before-upload="handleFile"
:http-request="handleFile"
:show-file-list="false"
drag
multiple
action=""
>
<i class="el-icon-plus avatar-uploader-icon"></i>
</el-upload>
handleFile(file) {
this.uploadImg(file)
},
uploadImg(file) {
const formData = new FormData()
formData.append('files', file.file)
Object.keys(this.housingParam).forEach((key) => {
formData.append(key, this.housingParam[key])
})
api.addHousingPictureById(this, formData).then((res) => {
if (res.data === true) {
this.$message({
message: '图片上传成功!',
type: 'success'
})
this.$emit('getHousingInfoById')
} else {
this.$message({
message: '图片上传失败!',
type: 'warning'
})
}
})
}
图片拖拽点击上传
最新推荐文章于 2024-11-07 10:17:21 发布