element upload 上传文件报错status of undefined

upload 上传报错

场景再现:点击编辑数据,修改上传文件,确定提交修改,关闭弹窗,清空数据和清空附件。

在这里插入图片描述

错误提示:上传报错,下图; Uncaught TypeError: Cannot set property ‘status’ of undefined

控制台错误

报错原因:设置了:file-list=“fileList”,filelist为只读,修改后就会报错 Cannot set property ‘status’ of undefined

解决方法:在成功回调中用setTimeout清空上传列表即可解决。

核心代码

setTimeout(() => {
    this.$refs.upload.clearFiles();
   }, 100);

具体方法代码

this.$refs[forms].validate((valid) => {
          if (valid) {
            EditTrainingRecord(this.form)
              .then((res) => {
                if (res.status == 200) {
                  this.folder.folderId = this.form.accessory;
                  this.submitUpload();
                  this.$message({
                    message: "添加成功",
                    type: "success",
                    center: true,
                    showClose: true,
                  });
                  //清空附件列表
                  setTimeout(() => {
                    this.dialogFormVisible = false;
                    this.$refs.upload.clearFiles();
                  }, 100);

                  this.getList();
                } else {
                  this.$message({
                    message: res.content,
                    type: "warning",
                  });
                }
              })
              .catch((res) => {
                this.dialogVisible = false;
                this.$message({
                  message: "系统异常,请联系管理员",
                  center: true,
                  type: "error",
                });
              });
          } else {
            console.log("error submit!!");
            return false;
          }
        });
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值