I'd like to retrieve the image source from vuex and display it by looping through a div
Here's what I have in mind:
<div v-for="({image}, index) in allData" :key="index">
<img :src="image" :alt="index"/>
</div>
<script>
import {mapState} from 'vuex';
export default{
computed: {
...mapState([
'allData'
])
}
}
</script>
This is data.js
export default [
{image: "./image/image1"},
{image: "./image/image2"},
{image: "./image/image3"}
]
This is state.js
import data from './data'
export default {data};
This is index.js
import Vue from 'vue'
import Vuex from 'vuex'
import state from './state'
Vue.use(Vuex)
export default new Vuex.Store({state})
https://i.sstatic.net/oUAAN.png
Thank you!