I'm having this problem and idk how fix this! Error in render:
TypeError: _vm.img.loadImg is not a function.
I wanna show the pic with a method loadImg(id), how I use this? I'm a novice in vue.
Code:
import Vue from 'vue'
import AsyncComputed from 'vue-async-computed'
Vue.use(AsyncComputed)
export default {
name: "Sell",
components: {
Header
},
data() {
return {
divBar: DivBar,
iconNext: IconNext,
iconVaca: IconVaca,
iconPeso: IconPeso,
iconPreco: IconPreco,
iconLocal: IconLocal,
timelineItems: [],
errorObj: {
isSet: false
},
img: '',
}
},
computed: {
loadImg(id) {
this.$http.get(this.$api + "/midiasvenda/" + id)
.then(response => {
if (response.success != null) {
return response.success;
} else {
return Vaca
}
}).catch(error => {
return error;
})
return Vaca;
}
}
<template>
<div v-else class="container-sell">
<div v-for="item in timelineItems" :key="item.id" class="container-cow">
<div class="left-content">
<div class="flock-image">
<img :src="img.loadImg(item.id)" alt="" class="cow">
</div>
</div>
</div>
</div>
</template>
Thanks for help guys!
img.loadImg(item.id)withloadImg(item.id), becauseloadImgfunction doesn't exist onimg.loadImgtomethods.this.$api+'/midiasvenda/'+idload the image itself?