Element级联列表最后一层显示为空

​ 根据后端接口返回数据,通过props属性进行匹配配置项,会出现这一问题。可用递归实现:

// 递归 处理级联列表问题
getTreeData(data) {
// 循环遍历json数据
for (var i = 0; i < data.length; i++) {
if (data[i].childList.length < 1) {
// children若为空数组,则将children设为undefined
data[i].childList = undefined;
} else {
// children若不为空数组,则继续 递归调用 本方法
this.getTreeData(data[i].childList);
}
}
return data;
},