I want to generate some v-chip objects with variable names and images. The source string of the image depends on the name. When I bind the name to the source string the image doesn't load. I already read a similar question with a solution (Vue.js img src concatenate variable and text) but it just doesn't work for me.
I tried two different ways as you can see in the code. One with binding a props and one with a computed function. Both not working.
<template>
<div>
<v-chip v-model="perso">
<v-avatar>
<img :src="'../assets/' + perso_name + '.png'"> <!--Doesn't work-->
</v-avatar>
{{perso_name}}
</v-chip>
<v-chip v-model="perso">
<v-avatar>
<img :src="'../assets/' + foo + '.png'"> <!--Doesn't work-->
</v-avatar>
{{perso_name}}
</v-chip>
<v-chip v-model="perso">
<v-avatar>
<img src="../assets/Jon.png"> <!--This works-->
</v-avatar>
{{perso_name}}
</v-chip>
</div>
</template>
<script>
export default {
data () {
return { perso: true }
},
name: 'Personal',
props: ['perso_name'],
computed: {
foo: function() {
return this.perso_name;
}
}
}
</script>
I don't get an error but the image isn't loading. It just shows the broken file icon.