element UI Upload 上传文件只能上传一次 ,第二次后无反应的问题的坑


主要原因是第一次上传文件后,浏览器还保存着我们已经上传的文件,所以要想继续上传文件,就需要在on-success钩子函数中r通过ef 拿到它的document元素进行清除已经上传的文件

<el-upload
                  class="upload-demo"
                  ref="upload"
                  :action="url"
                  :headers="headers" :on-success="handleAvatarSuccess"
                  :multiple="false"
                  :show-file-list="false"
                  :limit="1"
                  :auto-upload="true"
                >
                <!-- :before-upload="beforeAvatarUpload"    下载前要开启格式与大小判断的话,el-upload标签中加上before-upload 属性 -->
                  <img src="/image/table/upload.png" slot="trigger" />
                </el-upload>
handleAvatarSuccess(res, file) {
      // this.myData= file;
      this.$refs.upload.clearFiles(); //上传成功之后清除历史记录
      this.handleInitTableData();  //初始化表格数据
    },

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM