赞
踩
<el-upload
ref="uploadexcel"
class="upload-demo"
:limit="1"
:show-file-list="false"
:before-upload="beforeUploadExcel"
:http-request="importSceneDicWord"
:file-list="fileListExcel"
style="display: inline-block"
>
<span class="userbtn marginL15">
<text>导入Excel</text>
</span>
</el-upload>
<script> export default { data() { return { fileListExcel: [], }; }, methods: { async importSceneDicWord(file) { let formdata = new FormData();//需要用formdata转成二进制流 formdata.append("file", file.file);//"file"是后端参数 let res = await importSensitiveAPI(formdata); if (res.code == 200 || res.code == "200") { this.$refs.uploadexcel.clearFiles(); //上传成功后清除内容,不然第二次上传没用 this.fileListExcel = [];//清空列表 ElMessage({ message: "文件上传成功", type: "success", }); } else { this.$refs.uploadexcel.clearFiles(); //上传失败后清除内容,不然第二次上传没用 this.fileListExcel = [];//清空列表 ElMessage.error("文件上传失败 " + res.data); } }, } } </script>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。