递归函数(vue-ant-design 递归加载Tree组件)
getUserInfo(){const menu = localStorage.getItem('menu');if (menu === '' || menu === 'undefined' || menu === 'null' ) {return false;}c...
·
getUserInfo(){
const menu = localStorage.getItem('menu');
if (menu === '' || menu === 'undefined' || menu === 'null' ) {
return false;
}
const _menu = JSON.parse(localStorage.getItem('menu'));
if (_menu && _menu.length >= 1) {
_menu.forEach((item,index)=>{
this.treeData.push(this.getTreeNode(item,index))
})
}
},
getTreeNode(item,index){
let childrenNode={
title:item.purview_name,
key:index
};
if(item.child && item.child.length){
childrenNode.children = [];
item.child.forEach((subItem,subIndex) =>{
let subkey = `${index}-${subIndex}`
childrenNode.children.push(this.getTreeNode(subItem,subkey))
});
}
return childrenNode
}
更多推荐
已为社区贡献2条内容
所有评论(0)