SOURCE

var type1=[{className: '男鞋',id:'1'},{className: '女鞋',id:2}]
var type2 = [{className: '女士凉鞋',fatherId: 2,id:3},{className: '女士单鞋',fatherId: 2,id: 4}]
var type3 = [{className: '单鞋',fatherId: 4,id: 11},{className: '鱼嘴鞋',fatherId: 4,id: 12}]

var max = '女鞋-女士单鞋-单鞋,女鞋-女士单鞋-鱼嘴鞋,女鞋-女士凉鞋,男鞋'

var name1=[],name2=[],name3=[],maxArr=[];

for (let i in type3) {
  for (let j in type1) {
		for (let k in type2) {
			if(type3[i].fatherId == type2[k].id){
        maxArr.push(`${type2[k].className}-${type3[i].className}`)
        var id2 = type2[k].fatherId;
        break;
      }
    }
    if(id2 == type1[j].id){
      // console.log(maxArr)
      let str1 = `${type1[j].className}-${maxArr[maxArr.length-1]}`;
      maxArr[maxArr.length-1] = str1;
      // 已经拼接成功了,不需要余下的重复拼接
      break;
    }
  }
  
}




console.log(maxArr)
console 命令行工具 X clear

                    
>
console