Skip to content

Commit

Permalink
feat: 手动上传单个文件
Browse files Browse the repository at this point in the history
  • Loading branch information
songxingguo committed May 9, 2024
1 parent 69f8ae2 commit d039cc1
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/.vuepress/public/demo/HTMLBasic/EFileUpload.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
:file-list="fileList"
:auto-upload="false"
:on-change="uploadChange"
:http-request="httpRequest"
multiple
:limit="3"
>
Expand Down Expand Up @@ -85,7 +86,24 @@
.catch((err) => alert("出错"));
};
const uploadChange = (file, files) => {
console.log("file, files", file, files);
let formData = new FormData();
formData.append("uploadFile", file.raw);
console.log(formData);
// 调用接口上传文件
handleUploadFile(formData)
.then((res) => {
if (res && res.success) {
alert("上传成功");
//处理结果
} else {
alert(res?.message || "上传失败");
}
console.log(res);
})
.catch((err) => alert("出错"));
};
const httpRequest = (options) => {
console.log("options", options);
};
return { message, submitUpload, uploadChange };
},
Expand Down

0 comments on commit d039cc1

Please sign in to comment.