# 一道实战开发遇到的递归题目

122 次浏览

``````{value: "230000", label: "黑龙江省", pk: "1001Z01000000000SGGS", children: Array(13)}
children:
{value: "230100", label: "哈尔滨市", pk: "1001Z01000000000SGGT", children: Array(14)}
{value: "230200", label: "齐哈尔市", pk: "1001Z01000000000SGHD", children: Array(10)}
{value: "230300", label: "鸡西市", pk: "1001Z01000000000SGHV", children: Array(4)}
children:
{value: "230301", label: "市辖区", pk: "1001Z01000000000SGHW", children: Array(6)}
{value: "230321", label: "鸡东县", pk: "1001Z01000000000SGI3"}
{value: "230381", label: "虎林市", pk: "1001Z01000000000SGI4"}
{value: "230382", label: "密山市", pk: "1001Z01000000000SGI5"}``````

2019-06-14 提问
2 个回答
``````let data = [230000，230100，230321]
let PArr = [] // 所有省
let pIndex = PArr.findIndex(item => item.value === data[0])
let CArr = PArr[pIndex].children
let cIndex = CArr.findIndex(item => item.value === data[1])
...

``````
``````{value: "230000", label: "黑龙江省", pk: "1001Z01000000000SGGS", children: Array(13)}
children:
{value: "230100", label: "哈尔滨市", pk: "1001Z01000000000SGGT", children: Array(14)}
{value: "230200", label: "齐哈尔市", pk: "1001Z01000000000SGHD", children: Array(10)}
{value: "230300", label: "鸡西市", pk: "1001Z01000000000SGHV", children: Array(4)}
``````

``````{
230000: {value: "230000", label: "黑龙江省", pk: "1001Z01000000000SGGS", children: Object}
children:{
230100：{value: "230100", label: "哈尔滨市", pk: "1001Z01000000000SGGT", children: Object}
230200：{value: "230200", label: "齐哈尔市", pk: "1001Z01000000000SGHD", children: Object}
230300：{value: "230300", label: "鸡西市", pk: "1001Z01000000000SGHV", children: Object}
}
}``````

``object[230000]['children'][230100]['children'][230321]``