Siang Kian Tan
Siang Kian Tan

Reputation: 33

If the object name of array with space in v-for

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

Answers (1)

Tommy
Tommy

Reputation: 2453

You can write it like {{ name['Txn Group'] }} and it will work properly.

Upvotes: 2

Related Questions