vue循环请求同一个接口,等接口返回数据之后在进行下次循环

  • Post author:
  • Post category:vue


async 方法名() {
      for (let i = 0; i < this.mlList.length; i++) {
        for (let j = 0; j < this.mlList[i].child.length; j++) {
          const res = await postapplicationJson(
            {
              id: this.$route.params.id,
              catalogID: value,
              parentID: this.mlList[i].id,
              childID: this.mlList[i].child[j].id
            },
            '/goods/across/syncCatalogAndGoods'
          )
          if (res.code == 1001) {
            this.loading = false
            this.$set(this.mlList[i].child[j], 'msg', '克隆成功')
          } else {
            this.$set(this.mlList[i].child[j], 'msg', res.msg)
            this.loading = false
          }
        }
      }



版权声明:本文为qq_43358160原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。