递归生成树形菜单
buildtree(list, arr, parentId) {
list.forEach((item) => {
if (item.parentId === parentId) {
var child = {
key: item.id,
value: item.id, // value是给modal的select用的,2者属性不一样
title: item.name,
scopedSlots: { title: 'title' },
children: [],
}
this.buildtree(list, child.children, item.id)
if (child.children.length === 0) {
delete child.children
}
arr.push(child)
}
})
},