LXH_HX
诛九戒
2021-01-22 21:52

VUE中使用递归为什么我的只调用一次?

  • vue.js
  • javascript
API.getFileClass()
        .then((res) => {
          if (res) {
            console.log("所属分类", res);
            // let baby = res.data;
            this.options5 = res.data;
            fori(this.options5);
            function fori(baby) {
              console.log(baby, "222222222");
              let size = "";
              let b = {};
              for (var i = 0; i < baby.length; i++) {
                const arr = baby[i];
                let a = arr.children;
                console.log(arr, "wwwwwwwwwww");
                if (a.length > 0) {
                  size = a.length;
                  b = arr;
                } else {
                  delete arr.children;
                }
              }
              if (size > 0) {
                console.log(size, "33333333333");
                fori(b);
              }
            }
          }
        })
        .catch((e) => {
          console.log(e);
        });

 

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答

为你推荐

换一换