原本树型数组内容:
展开成普通一维数组
js方法:
treeConvertToArr (arr) {
let res = [];
for (let i = 0; i < arr.length; i++) {
if (arr[i].children) {
res = res.concat(this.treeConvertToArr(arr[i].children));
//删除父级的children属性,须保留children则把这行删除
delete arr[i].children
}
res.push(arr[i]);
}
return res;
}