递归调用判断key ,来切换value
// 树形结构递归调用 const cheangeAreaData = (data) => { // console.log(data) const arr = [] data.forEach(item => { for (const key in item) { // 判断key if (key === 'meta') { item[key] = item[key].title arr.push(item) } // 判断key if (key === 'children') { if (item.children.length > 0) { cheangeAreaData(item.children) // 递归调用 } else { delete item[key].children } } } }) return arr }