要访问列表中标签中的信息,我该怎么办?我可以使用点符号吗? Javascript正在后端使用,javascript正在前端使用。
HTML:
<div>{{ GameData }}</div>
JAVASCRIPT:
{
"player_stat_summary": [
{
"id": 1,
"stats": {
"id": 1,
"average_node_capture_assist": 0,
"max_node_neutralize_assist": 0,
"total_minion_kills": 0,
"max_champions_killed": 0,
"total_champion_kills": 0,
"average_champions_killed": 0,
"average_num_deaths": 0,
"max_node_capture": 0,
"max_objective_player_score": 0,
"total_neutral_minions_killed": 0,
"max_assists": 0,
"average_combat_player_score": 0,
"max_node_capture_assist": 0,
"average_objective_player_score": 0,
"max_team_objective": 0,
"total_assists": 0,
"average_node_capture": 0,
"average_total_player_score": 0,
"average_team_objective": 0,
"average_node_neutralize": 0,
"max_node_neutralize": 0,
"average_node_neutralize_assist": 0,
"average_assists": 0,
"max_total_player_score": 0,
"max_combat_player_score": 0,
"total_turrets_killed": 0,
"total_node_neutralize": 0,
"total_node_capture": 0
},
"player_stat_summary_type": "Coop",
"wins": 100,
"losses": 0
}
],
"time_stamp": "2015-05-22T15:54:43.069814Z",
"summoner_id": 0
}
答案 0 :(得分:0)
您可以使用点表示法和字符串表示法。例如,在给定数据中,您可以以
的形式访问数据的第一个对象GameData.player_stat_summary[0]
OR
GameData["player_stat_summary"][0]
您可以将“player_stat_summary”的任何属性设置为:
GameData.player_stat_summary[0].id
OR
GameData["player_stat_summary"][0]["id"]
同样可以访问更多层次结构。