var newArr = []新建一個數據,用於存儲扁平化化后的數組
flatData(arr) {
arr.forEach(item => {
this.res.push(item)
item.children && item.children.length > 0 ? this.flatData(item.children) : ""
item.children = '' //如果扁平化后的數組需要顯示父子層級,可以把這一項刪除
})
}
