0

I'm receiving a json formatted in kebab-case, like so :

{name: "田中 太郎", profile-image: "", visit-frequency: "10"}

I have multiple objects that I want to display in my template, so I'm using a v-for. But I can't figure out how to display profile-image or visit-frequency, as I obviously can not do :

<li class="cell" v-for="item in members">
  <img :src="item.attributes.profile-image" :alt="item.attributes.name">
</li>

I'm thinking about a loop on my list of objects and rename those attributes, but I feel like there something better than that.

j-printemps
  • 1,288
  • 11
  • 21
  • 1
    Could you do `item.attributes['profile-image']`. Sorry I'm not vue programmer but you access kebab-case like this in regular javascript – codtex Sep 14 '17 at 07:08
  • Quick answer ~ `item.attributes['profile-image']`, `item.attributes['visit-frequency']`, etc – Phil Sep 14 '17 at 07:08

0 Answers0