Reputation: 33
The object name has space like 'Apple Juice','Orange Juice', so how can I use it in v-for?
<div id="box" v-if="!loading">
<table>
<thead>
<tr>
<th>Name</th>
<th>Total Sales</th>
</tr>
</thead>
<tbody>
<tr v-for="name in Beverage" v-bind:key="name">
<td>{{name.Txn Group}}</td> //error
<td>{{name.TotalSales}}</td>
</tr>
</tbody>
</table>
</div>
I called API and get JSON data, so I unable to change the object name. Thanks.
Upvotes: 1
Views: 261
Reputation: 2453
You can write it like {{ name['Txn Group'] }}
and it will work properly.
Upvotes: 2