vue 递归遍历数据

    function changeTree(val) {
      let arr = [];
      if (val.length !== 0) {
        val.forEach(item => {
          let obj = {};
          obj.id = item.path;
          obj.label = item.name;
          if (item.children.length >= 1) {
            obj.children = this.changeTree(item.children);
          }
          arr.push(obj);
        });
      }

      return arr;
    },
原文地址:https://www.cnblogs.com/lovetl/p/11989855.html