睡大觉啦 2023-01-16 19:52 采纳率: 0%
浏览 49
已结题

for循环执行一次就不执行了,数组长度有3,但是只执行第一次

for循环执行一次就不执行了,数组长度3,但是只执行第一次

submitSupply() {
      this.$refs["supplyForm"].validate((valid) => {
        let arr = this.supplyForm.errCode.replace(/[,]/g, ",").split(",");
        if (valid) {
          supplyPost.call(this, arr);
        } else {
          return false;
        }
      });
async function supplyPost(errCodeArray) {
        for (let index = 0; index < errCodeArray.length; index++) {
          try {
            let params = {
                startTime: this.supplyForm.startTime,
                endTime: this.supplyForm.endTime,
                repeatChId: this.supplyForm.repeatChId,
                errCode: errCodeArray[index],
              },
              ajaxType = "Ajax2",
              url = Api.createSupply;
            let res = await window[ajaxType](url, params);
            this.$message.success(res.message);
          } catch (err) {}
        }
        this.showSupply = false;
      }
    },

  • 写回答

3条回答 默认 最新

  • Huazie 优质创作者: 编程框架技术领域 2023-01-16 20:31
    关注
    • 打印一下err看看,第一次处理是不是报错了
    评论

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 6月27日
  • 创建了问题 1月16日