自定义el-upload文件上传,失败的文件不回显

                  <el-upload
                    ref="uploadFile"
                    class="upload-demo"
                    action="#"
                    :http-request="uploadFile"
                    :file-list="filesPathList"
                    list-type="picture"
                    multiple
                  >
                    <el-button size="small" type="primary">点击上传</el-button>
                  </el-upload>
    uploadFile(file) {
    // 自定义参数
this.licensePath = URL.createObjectURL(file.file) this.submitForm.licensePath = file.file var formData = new FormData() formData.append('file', this.submitForm.licensePath) formData.append('imageSence', this.submitForm.imageSence) formData.append('imageType', this.submitForm.imageType) image.uploadImage(formData).then((res) => { if (res.success) {this.$message.success('上传成功') } else { // 失败删除回显列 const idx = this.$refs.uploadFile.uploadFiles.findIndex(item => item.uid === file.file.uid) this.$refs.uploadFile.uploadFiles.splice(idx, 1) } }) }

 

posted @ 2022-07-26 11:02  Stitchhhhh  阅读(1970)  评论(0编辑  收藏  举报