vue Element组件上传文件-去掉文件列表

 <div style="float: right;display: inline-block">
   <form class="form-horizontal upload-block" id="upload">
     <el-upload
       class="upload-demo"
       ref="upload"
       action="/api/features/upload"
       :limit="1"
       accept='.xlsx'
       :on-success="uploadSuccess"
       :on-error="uploadError">
       <el-button size="small" type="primary" style="float: right;margin-left:10px;" class="taskBtn">点击上传el-button>
       
     el-upload>
   form>
 div>

javascript

	  //文件上传事件
      uploadSuccess(res) {
        console.log(res);
        this.$refs.upload.clearFiles(); //去掉文件列表
        this.$message({  //弹窗
          message: 'Excel导入成功',
          type: 'success',
          center: true,
          duration: 1000
        });
      },
      uploadError(res){
        console.log(res);
        this.$refs.upload.clearFiles(); //去掉文件列表
        this.$message({  //弹窗
          type: 'error',
          message: 'Excel导入失败!',
          center: true,
          duration: 1000
        });
      }

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