[Vuejs]-How to load locally stored images conditionally in Vuejs?

0👍

First. I think you should provide image link on your API Response (so you should add image link column on your database table). Or if you insist, based on your case, you can use this:

<div v-if="item">
  <h1>Price: {{ item.email }}</h1>
  <img :src="getPic(item.email)"/>
</div>

and in your method:

getPic(src) {
  return "@/assets/" + src.substring(0, src.lastIndexOf("@")) + ".png"
}

But I still really think you should store iamge link in your database

Leave a comment