美文网首页
vue递归调用接口批量上传和 组件定时器另一种销毁方法

vue递归调用接口批量上传和 组件定时器另一种销毁方法

作者: 用技术改变世界 | 来源:发表于2021-08-09 19:53 被阅读0次

1.参数:传递一个数组

    recursiveUpload(files) {

      let upload_data = new FormData();

      const len = files.length;

      if (this.current_index < len) {

        upload_data.append("file", files[this.current_index]);

        Service.uploadTheme(upload_data)

          .then((res) => {

            if (res) {

              this.current_index++;

              this.recursiveUpload(files);

            }

          })

          .catch(() => {

            this.disabledUpload = false;

            this.message.close();

          });

      } else {

        this.current_index = 0;

        this.message.close();

        this.disabledUpload = false;

        this.$message({

          message: "上传成功",

          type: "success",

          showClose: true,

        });

      }

    },

相关文章

网友评论

      本文标题:vue递归调用接口批量上传和 组件定时器另一种销毁方法

      本文链接:https://www.haomeiwen.com/subject/asygmltx.html