Reputation: 127
I have this vue function. That should return the img srs, dynamically. For some reasons, it is not reading the string as a local file. Image is not showing.
script
showSuccessPercentage(recieved) {
if (typeof recieved === "object" && recieved != null) {
if(recieved["successRunsPercentage"] > 50) {
return "'../assets/img/rainy.png'"
}
}
else return "N/A";
},
HTML
<img class= "w-10" :src="showSuccessPercentage(currentView.worstReport) " alt="Organization Icon" />
looks simple. Not sure why it's giving me a hard time.
Upvotes: 1
Views: 1677
Reputation: 3238
You need to use require
method to get the local image render in Vue.app.
showSuccessPercentage(recieved) {
if (typeof recieved === "object" && recieved != null) {
if (recieved["successRunsPercentage"] > 50) {
return require('../assets/img/rainy.png')
}
}
else return "N/A";
},
Upvotes: 1