需求:上传文件时,携带“文件名”和“文件类型”参数进行请求。
重要部分代码:
<el-upload ref="upload" action="/test/loadDictGoodsForColCebToDec"
:before-upload="beforeUploadFile"
:data="fileData">
</el-upload>
js重要部分代码:
data() {
return {
fileData: null,
}
},
methods: {
beforeUploadFile(file){
this.fileData = {
uploadFileFileName: file.name,
uploadFileContentType: file.type
}
let promise = new Promise((resolve) => {
this.$nextTick(function () {
resolve(true);
});
});
return promise;
}
}
最终请求效果: