0👍
what you can do is store the response in this.products and no extra step is needed then in the img tag you can do is use template literals directly on the :src binding something like this
<div v-for="prod in products" :key="prod.id">
<v-img :src="`/assets/${prod.productFileName}`" />
<script>
methods: {
getProducts() {
axios.get("https://localhost:44397/api/Product/List")
.then(res => {
this.products = res.data;
})
}
}
and make sure that image is located in that location, otherwise the image will not be displayed
- [Vuejs]-Vue and UglifyJS error when running 'npm run build'
- [Vuejs]-Unit Testing VueJS Karma Mocha ExpectJS nextTick not working
-1👍
You have change your code like below.
this.products.forEach(prod => {
prod.productFileName = '/Uploads/' + prod.productFileName
});
Since this is a script you can simply append the string.
- [Vuejs]-V-model with dynamically added property
- [Vuejs]-Transition's hook creates issue once destroyed and called back
Source:stackexchange.com