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

2021-08-09  本文已影响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,

        });

      }

    },

上一篇 下一篇

猜你喜欢

热点阅读