JS 树型结构数据简易递归
js树型结构数据简易递归
// item内的值根据实际情况更换
replaceValueInTree (tree) { const result = [] tree.forEach((item) => { let children = item.children || [] if (Array.isArray(children) && children.length > 0) { children = this.replaceValueInTree(children) } let newItem = { title: item.categoryName, value: item.id, checked: false, selected: false, children: children } result.push(newItem); }) return result }