Consider the JSON data below:
{
"games": [
{
"id": 1,
"init_date": "2020-02-11T07:47:33.627+0000",
"players_in_game": [
{
"id": 1,
"player": {
"id": 1,
"player": "Jack Bauer",
"email": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="02682c6063776770426176772c656d7430">[email protected]</a>"
}
},
{
"id": 2,
"player": {
"id": 2,
"player": "Chloe O'Brian",
"email": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="8eeda0e1ecfce7efe0ceedfafba0e9e1f8">[email protected]</a>"
}
}
]
},
{
"id": 2,
"init_date": "2020-02-11T08:47:33.627+0000",
"players_in_game": [
{
"id": 3,
"player": {
"id": 1,
"player": "Rome Jones",
"email": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="cea4e0acafbbabbc8eadbabbe0a9a1b8fc">[email protected]</a>"
}
},
{
"id": 4,
"player": {
"id": 2,
"player": "Ludacris",
"email": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="82e1acede0f0ebe3ecc2e1f6f7ace5edf4">[email protected]</a>"
}
}
]
},
]
}
I am looking to display a Player VS another player for each 'players-in-game' entry, like so:
**PLayer 1 VS PLayer 2**
Jack Bauer Chloe O'Brian
Rome Jones Ludacris
However, I'm having trouble with the implementation. Here is the code snippet I have tried:
<tr v-for="(general, index) in getGamesAll.games" v-bind:key="index">
<td>Game {{general.id}}</td>
<td v-for="(gamePlayer, j) in general" :key="j">
{{general.players_in_game.player.player}}
</td>
<td>vs</td>
<td v-for="(gamePlayer, j) in general" :key="j">
{{general.players_in_game.player.player}}
</td>
</tr>
This approach is flawed as it does not specify which player within the 'players-in-game' object to access. What would be the correct way to achieve this desired output?