<template>
<div>
<el-upload
class="upload-demo"
action=""
:http-request="handleUpload"
:on-change="uploadChange"
:show-file-list="false"
>
<el-button size="small" type="text">上传</el-button>
</el-upload>
</div>
</template>
<script>
export default {
name: 'UploadImage',
data() {
return {
}
},
methods: {
handleUpload(file) {
},
uploadChange(file) {
this.$emit('upload', file)
}
}
}
</script>
引用上传组件
<UploadImage @upload="(file)=>upload(file,row)" />
upload(imgFile, row) {
const form = new FormData()
console.log(FormData)
form.append('file ', imgFile.raw)
form.append('Code', row.Code)
//调上传图片接口
uploadImg(form).then(res => {
if (res.ReqCode === 0) {
this.$message({
type: 'success',
message: res.ReqMsg
})
this.getList()
}
})