<el-upload
ref="upload"
action="#"
:on-change="changeFile"
:auto-upload="false"
class="upload-demo"
style="height: 30px;"
:show-file-list="false"
>
<el-button :disabled="tableData.length>=20" type="primary" plain size="small">图片上传</el-button>
</el-upload>
async changeFile(file) {
const formdata = new FormData()
formdata.append('file', file.raw) //拿到上传文件的数据
if (!file.raw.type.startsWith('image/')) { //判断格式
this.$message.warning('只能上传图片格式')
return
} else {
//上传调用的接口
}
},