3

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.

4
  • The extension png is an error. It will not work even if you change it to jpg. Commented Jan 21, 2019 at 13:43
  • Try to use <v-img :src="require('@/assets/profile.jpg')" aspect-ratio="2.75" ></v-img> instead Commented Jan 21, 2019 at 13:49
  • 1
    To. Jns Thanks! Commented Jan 21, 2019 at 14:21
  • Converted my comment to an answer with an explanation (as you asked for) Commented Jan 21, 2019 at 14:30

2 Answers 2

8

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>

Sign up to request clarification or add additional context in comments.

Comments

5

This Work for me...

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

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.