tree结构统一修改属性名(递归)

 1 //data为需要修改的tree,这里主要是为antd design 里面select规范数据
 2 const ass = (data) => {
 3         let item = [];
 4         data.map((list, i) => {
 5                 let newData = {};
 6                 newData.key= list.id;
 7                 newData.value = list.id;
 8                 newData.title = list.name;
 9                 newData.children = list.children  ? ass(children) : [];    //如果还有子集,就再次调用自己
10                 item.push(newData);
11         });
12         return item;
13  }

 

posted @ 2018-09-20 17:28  小欣子  阅读(2475)  评论(0编辑  收藏  举报