前言:
实现单文件上传!此文章仅记录代码如何实现,便于后期项目学习使用!!
代码实现:
<!--********** View ********** -->
<el-uploadclass="upload-demo":http-request="UploadFile":show-file-list="false"><el-button type="success">上传模板</el-button>
</el-upload>//------------ script -----------//上传模板
async function UploadFile(file) {if (JSON.stringify(file.file) != "{}") {formData.append("file", file.file);let res = await UploadFileAPI(formData);if (res.data.message == "上传成功") {ElMessage({type: "success",message: "上传成功",});}}
}