我在访问主干集合中的嵌套值时遇到问题。到目前为止,我已经设法获得了一些价值。这是 html 和 javascript 代码以及我的结果: 代码:http: //jsfiddle.net/mM2Mk/4/ 结果: http ://tinypic.com/r/2qn3amu/6
但是,此解决方案中的集合不遵循我实际 api 的结构。我试图开始工作的结构如下所示:
teamsCollection = new Standings.Collections.TeamsCollection([
{
credit: {
message: "Provided by ",
link: "",
logoUrl: ""
},
metadata: { },
groups: [
{
labels: [ ],
standings: [
{
team: {
id: 9369,
name: "IF Elfsborg",
shortName: "Elfsborg",
link: ""
},
stats: [
{
name: "gp",
value: 30
},
{
name: "w",
value: 18
},
{
name: "d",
value: 5
},
{
name: "l",
value: 7
},
{
name: "gf",
value: 48
},
{
name: "ga",
value: 29
},
{
name: "gd",
value: 19
},
{
name: "pts",
value: 59
}
]
},
{
team: {
id: 19740,
name: "BK Häcken",
shortName: "Häcken",
link: ""
},
stats: [
{
name: "gp",
value: 30
},
{
name: "w",
value: 17
},
{
name: "d",
value: 6
},
{
name: "l",
value: 7
},
{
name: "gf",
value: 67
},
{
name: "ga",
value: 36
},
{
name: "gd",
value: 31
},
{
name: "pts",
value: 57
}
]
},
此代码为我们提供了一些运动结果,例如比赛次数、获胜次数、净胜球数等。这只是集合中其他几支球队中的一支。我现在的问题是如何循环嵌套值并显示它们,就像我在我的示例中所做的那样(上面的小网址)。我的目标是获取团队名称以及统计数据并将它们显示在 html 中。以此类推其他团队。