- 递归返回正确数据
- 尽早返回
-
findNode(list, id) { let result = null for (let i = 0; i < list.length; i++) { if (list[i].ID === id) { result = list[i] console.log('selected', result) break } else { const node = this.findNode(list[i].Children, id) if (node != null) { result = node break } } } return result },