将递归得到的对象push到数组中
let selections = [];
for (let leaf of this.tree) {
let result = this.recursion(this.items, leaf);
selections.push(result);
}
递归函数
recursion(data, id) {
let result;
if (!data) {
return;
}
for (var i = 0; i < data.length; i++) {
let item = data[i];
if (item.id === id) {
result = item;
break;
} else if (item.children && item.children.length > 0) {
result = this.recursion(item.children, id);
}
}
console.log(result);
return result;
},
this.items为树结构的数据
items: [
{
id: 1,
name: 'Vuetify Human Resources',
children: [
{
id: 2,
name: