<el-upload
action="#"
:http-request="FJ_Upload"
:limit="3"
:file-list="fileList">
<el-button size="small" type="primary">点击上传</el-button>
</el-upload>
data() {
return {
fileList: [],
form: {
appName: "",
version: "",
operationName: "",
uploadTime: "",
},
};
},
// 上传事件
FJ_Upload(param) {
var formData = new FormData();
formData.append('appFile', param.file);
formData.append("version",this.form.version);
this.flieParam = formData;
},
//确定时间
async submintNew() {
const that = this;
const res = await fetch('http://192.168.2.xx:8083/im/saveImAppInfo', {
method: 'post',
body: this.flieParam,
})
// if (res.downloadUrl) {
// that.$message.success('获取数据成功');
// this.form = Object.assign(this.form , res)
// } else {
// that.$message.error('暂无数据');
// }
},
fetch:的请求头不需要设置,post 就需要’Content-Type’: ‘multipart/form-data’
headers: {
'Accept': 'application/json',
//不需要写'Content-Type': 'multipart/form-data',自动是form -data
// 'Content-Type': 'multipart/form-data',
},