I'm trying to display all images that exist on a host (server), in one directory (charts) into a vue page instead of having to manually list them all inside of data and therefore having to rebuild with npm every time I want to add an image. The code I have working today is below, any suggestions would be greatly appreciate.
<template>
<div id="app" class="media-display">
<img class="media-post" v-for="url of images" :key="url" :src="url + '?rnd=' + cacheKey" />
</div>
</template>
<script>
import DateTime from './lib/DateTime'
import moment from 'moment'
export default {
el: '#app',
data() {
return {
images: ['/charts/chart1.png', '/charts/chart1.png'],
cacheKey: +new Date(),
}
},
created() {
setInterval(() => {
this.cacheKey = +new Date()
}, 10000)
},
destroyed() {
clearInterval(this.interval)
},
}
</script>
<my-component>, just pass the data to the view, and pass that to the component<my-component :images="images"></my-component>where theimagesvariable was sent to from the server to the view that renders the component.