// 调用 treeData(list, 0)list:数组, 0:起始id
treeData(list, rootValue) {
var arr = [];
list.forEach((item) => {
if (item.pid === rootValue) {
const children = this.treeData(list, item.id);
if (children.length) {
item.children = children;
}
arr.push(item);
}
});
return arr;
},