我正在使用此https://codepen.io/VividD/pen/fIFJt建立家庭关系 我想首先得到父亲和母亲,然后是父亲的父亲和母亲,母亲的母亲和母亲,它将继续为每个父母,直到我达到它的结束。这种形式需要数据。
function getData() {
return {
"name": "Clifford Shanks",
"born": 1862,
"died": 1906,
"location": "Petersburg, VA",
"parents": [
{
"name": "James Shanks",
"born": 1831,
"died": 1884,
"location": "Petersburg, VA",
"parents": [
{
"name": "Robert Shanks",
"born": 1781,
"died": 1871,
"location": "Ireland/Petersburg, VA"
},
{
"name": "Elizabeth Shanks",
"born": 1795,
"died": 1871,
"location": "Ireland/Petersburg, VA"
}
]
},
{
"name": "Ann Emily Brown",
"born": 1826,
"died": 1866,
"location": "Brunswick/Petersburg, VA",
"parents": [
{
"name": "Henry Brown",
"born": 1792,
"died": 1845,
"location": "Montgomery, NC"
},
{
"name": "Sarah Houchins",
"born": 1793,
"died": 1882,
"location": "Montgomery, NC"
}
]
}
]
};
};
我无法为它创建无限循环,如果有人可以提供帮助那将非常感谢。