树结构遍历节点名字提取,这里提取的是el-tree数据结构,封装成函数
/** * 树形数据提取节点 * @param {*} data */ export function treeDataGetnode (data) { var res = [] var child=function(v){ if(typeof(v.children)!='undefined' && v.children.length>0){ for(var i=0;i<v.children.length;i++){ res.push(v.children[i].orgname) child(v.children[i]) } } } for(var k = 0; k < data.length; k++) { res.push(data[k].orgname) if(typeof(data[k].children)!='undefined' && data[k].children.length>0){ child(data[k]) } } let set = Array.from(new Set(res)); return setRes }