el-upload 自定义上传成功 点击第二次上传没反应

<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>导入Exceltext>
   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>

你可能感兴趣的:(java,前端,javascript,elementui,vue)