记录一个递归的使用

130 阅读1分钟

阿  说来惭愧 

这是写过的第一个递归

好记忆不如记下来,所以

getContent(data) {
    data.forEach(item => {
        if (item.uuid === this.uuid) {
            const index = data.indexOf(item);
            data.splice(index, 1);
        } else {
            // 自己调用自己
            this.getContent(item.children);    
        }
    })
}