let form = new FormData();
// 后端接受参数 ,可以接受多个参数
form.append("submittime",date1)
form.append("file",this.file)
form.append("planId",this.uploadId)
form.append("pmId",this.$globalData.pmId)
// console.log(this.file,"这是上传的文件")
const loading = this.$loading({
lock: true,
text: '正在上传请稍后',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.7)'
});
addPdf(form).then(res=>{
loading.close();
console.log(res)
console.log("这是上传成功的东西")
this.$message({
type: 'success',
message: "上传成功"
})
this.selectGenerate()
this.listVisible=false
this.fileList=[]
}).catch(err=>{
console.log(err)
loading.close();
})
<!-- 上传文件form -->
<form
enctype="multipart/form-data"
method="post"
id="uploadForm"
>
<a
href="javascript:;"
class="file"
>选择文件
<label class="file-upload">
<input
class="drawUI-button"
type="file"
name="file"
id="inFile"
accept="application/zip"
@change="handleChange"
/>
</label>
</a>
</form>
handleChange(e) {
this.uploadFile = e.target.files[0];
console.log(e.target.files[0], "这是上传的文件");
// this.$emit("drawMap", document.getElementById("uploadForm"));
//有些地方(api)要的是 form 的节点
}