getTitle(list, id) {
var title = ''
for (let i = 0; i < list.length; i++) {
if (list[i].id == id) {
title = list[i].title
break
} else if (list[i].children && list[i].children.length > 0) {
title = this.getTitle(list[i].children, id)
if (title) return title
}
}
return title
}
<span>{{getTitle(typeList,item.id)}}</span>
递归找到id对应的值
最新推荐文章于 2023-04-13 15:36:15 发布