验证中...
tree2flateen.js
原始数据 复制代码
const tree = [
{
title: '标题1'
},
{
title: '标题2',
children: [
{
title: '标题2-1'
},
{
title: '标题2-2'
}
]
},
{
title: '标题3',
children: [
{
title: '标题3-1' ,
children: [
{
title: '标题3-1-1'
}
]
}
]
}
]
/**
* 树形菜单转化成一维数组(无级联关系)
* @param {Array} tree
*/
function tree2flatten (tree) {
let arr = [];
tree.forEach((item) => {
if (item.children) {
arr = arr.concat(tree2flatten(item.children))
}
// delete item.children;
arr.push(item);
});
return arr;
}

评论列表( 0 )

你可以在登录后,发表评论

8_float_left_people 8_float_left_close