[Vuejs]-Vue v-bind conditional local file

2👍

Got it to work by using it like so :

<img v-bind:src="user.photoUrl ? user.photoUrl : require('./assets/logo.png')">

0👍

<img v-bind:src="user.photoUrl ? user.photoUrl : require('./assets/logo.png')">

or if you are using a bundler like webpack, you can do

import logo from './assets/logo.png'


<img v-bind:src="user.photoUrl ? user.photoUrl : {logo}">
👤Luchux

Leave a comment