Answer the question
In order to leave comments, you need to log in
How to insert src property dynamically in vue.js?
My component. For img, I want to add a src property that comes from the server, but for some reason I can't do it. Where is the mistake?
<template>
<div class = "row__elements">
<div @click="event =>clickOnRow(elem, whichScreen)" class = "row__element" v-bind:class = "activeClass">
<img class = "file-info icon" :src = "imgSrc(elem)"/>
<div class = "file-info title"> {{elem.fileName}} </div>
<div class = "file-info size"> {{elem.sizeOrType}} </div>
<div class = "file-info date"> {{elem.dateOfChange}} </div>
</div>
</div>
</template>
imgSrc: function(elem){
console.log(this.elem.icon);
console.log(typeof(this.elem.icon));
console.log("не зис", elem.icon);
console.log(typeof(elem.icon));
return elem.icon
}
Answer the question
In order to leave comments, you need to log in
in that you should simply return elem
return elem
in or where your picture lies
, respectively, and wherever interpolation by type is wrong, it
will be right:src="imgSrc.img"
imgSrc.fileName
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question