타오르는선혈
타오르는선혈

Reputation: 97

vue assets image not load

src/assets/profile.jpg

enter image description here

<v-img src="../assets/profile.png" aspect-ratio="2.75"></v-img>

not load

I do not work. What is the reason?

By the way,

If you specify img tag src, the image will be output.

Upvotes: 3

Views: 10237

Answers (2)

Araoz
Araoz

Reputation: 183

This Work for me...

<template>
      <img :src=logo>
</template>

<script>
export default {
    data: () => ({
        logo: require('@/assets/profile.png')
    })
}
</script>

Upvotes: 5

Jns
Jns

Reputation: 3257

First you have to bind your image path to the src property and then you have to wrap the path in require('@/assets/profile.jpg') to let webpack know that this is a dependency.

So as mentioned as a comment, change your code to this: <v-img :src="require('@/assets/profile.jpg')" aspect-ratio="2.75" ></v-img>

Upvotes: 8

Related Questions