[Vuejs]-Because property photos.name comes back to me as if I'm doing it wrong?

0👍

photos is an array:

<img :src="'/img/rooms/'+room.photos[0].name" class="card-img-top br0" :alt="room.photos[0].name">

Or you can iterate:

<img v-for="photo in room.photos" :src="'/img/rooms/'+photo.name" class="card-img-top br0" :alt="photo.name">

0👍

photos is an Array of objects. Hence, Elements should be access via index.

You have to add one more iteration for photos via v-for.

<img v-for="photo in room.photos"
 :key="photo.id"
 :src="`/img/rooms/${photo.name}`"
 class="card-img-top br0"
 :alt="photo.name"
/>

-4👍

The image tag should be something like this:

<img src="/img/rooms/{{room.photos.name}}" alt="">

Leave a comment