【发布时间】:2021-08-21 13:48:46
【问题描述】:
我有从 api 以这种格式返回的数据:
[
{
"game": "Among Us",
"playTime": 5000,
"genre": "Multiplayer",
"platforms": [
"PC",
"Android"
]
}
]
我将它显示到引导表中,但平台内容不会显示!如何循环呢?
<table class="table table-striped">
<thead>
<tr>
<th scope="col">Game</th>
<th scope="col" sortable="name">Genre</th>
<th scope="col" sortable="area">Plateforms</th>
<th scope="col" sortable="population">Total play time</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let game of topGamesUsers">
<td>
{{ game.game }}
</td>
<td>{{ game.genre }}</td>
<td>{{ game.plateforms }}</td>
<td>{{ game.users }}</td>
</tr>
</tbody>
</table>
我应该将它们存储到另一个变量中还是可以在 html 文件中执行此操作?
【问题讨论】:
-
如果你想真正循环它 - 只需执行
ngFor="let platform of game.platforms" -
@tymeJV 在 tr 或 td 内?