setParentId (data, parentId) { if (this.pid != parentId) { this.level++ } this.pid == parentId var num for(var i = 0; i < data.length; i++){ num = i data[i].parentId = parentId data[i].level = this.level if (data[i].children && data[i].children.length > 0) { this.setParentId(data[i].children, data[i].name) } } if (num === data.length - 1) { this.level = 2 } return data
}
this.setParentId(this.data)