2👍
✅
you can do it using v-if
<div :class="[infoIconColor]">
<img v-if="infoLogoURL !== ''" :src="infoLogoURL" class="logo" alt="" @error="$event.target.src='link/picture.png'">
// v-else show your material icon
</div>
1👍
Use conditional rendering (v-if
and v-else
) to test whether the image exists and act accordingly:
<img v-if="infoLogoURL" :src="infoLogoURL" class="logo" alt="" />
<md-icon v-else>{{ infoSubIcon }}</md-icon>
If infoLogoURL
is defined, it will show the <img>
, otherwise it will show the <md-icon>
.
👤Dan
Source:stackexchange.com