async function doSubmitFile() {
const fileInput = document.getElementById('fileInput')
const fileObj = fileInput.files[0]
const formData = new FormData()
formData.append('file', fileObj)
try{
const response = await _axios.post("/api/employ/upload/", formData ,{headers:{'Content-Type': 'multipart/form-data'}})
console.log(response.data)
}catch(error){
ElMessage.error(`文件上传失败,${error}`)
}
}
function doSubmitFile2() {
const fileInput = document.getElementById('fileInput')
const fileObj = fileInput.files[0]
const formData = new FormData()
formData.append('file', fileObj)
_axios.post("/api/employ/upload/", formData, {headers: {'Content-Type': 'multipart/form-data'}}).then((res) => {
console.log(res.data)
}).catch((error) => {
ElMessage.error(`文件上传失败,${error}`)
})
}
标签:error,const,formData,await,fileObj,fileInput,async,两段,data
From: https://www.cnblogs.com/cloud-2-jane/p/18463224