vue3.0 树形(省市区),根据id获取name(递归)

const getTreeName=(list,id)=>{
      for (let i = 0; i < list.length; i++) {
        let a=list[i]
        if(a.Id===id){
          return a.Name
        }else{
          if(a.children && a.children .length>0){
            let res=getTreeName(a.children ,id)
            if(res){
              return res
            }
          }
        }
      }
    }

你可能感兴趣的:(javascript,vue.js,typescript)