[Vuejs]-How to use img src from vuex by looping

1👍

You’re missing the double quotes when binding the attribute. Remember that for local images you need to places them into the folder public/assets, then you can change your URLs to assets/your-image-name.jpg. More informations about static assets in Vue.JS can be found here.

<template>
   <div v-for="({ image }, index) in allData" :key="index">
      <img 
         :src="image" 
         :alt="index"
      />
   </div>
</template>

<script>
import { mapState } from 'vuex';

export default {
   computed: {
      ...mapState(['allData'])
   }
}
</script>

Leave a comment