vue遍历递归 - 古月容博客-php个人技术博客-技术交流分享

2018
IT资讯信息分享

vue遍历递归

多维数组遍历递归

 changeTree(val) {
      //递归删除末级空的children
      let arr = [];
      if (val.length !== 0) {
        val.forEach((item=> {
          let obj = {};
          obj.id = item.id;
          obj.label = item.label;
          obj.parentId = item.parentId;
          obj.name = item.name;
          obj.value = item.value;
          if (item.children.length >= 1) {
            obj.children = this.changeTree(item.children);
          }
          arr.push(obj);
        });
      }
      return arr;
    },


×

感谢您的支持,我们会一直保持!

扫码支持
请土豪扫码随意打赏

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

打赏作者
版权所有,转载注意明处:古月容个人博客 » vue遍历递归
标签: vue 递归 多维数组删除空值

发表评论

表情

网友评论(0)