0

I started to learn vueJs and it's my first time with framework. I got a problem and i don't know how to do.

 <img    
   :src="imgsource" 
 >


export default {
  name: "social-media",
  data() {
      return {
          imgsource: "../assets/img/icon-facebook.svg"
      }
  },
};

It's does not working. Can you explain me why ?

Thank you so much

1
  • Please check stackoverflow.com/q/40491506/6294072 if you are going to use a variable imgsource instead of just putting the path directly in the img tag Commented May 1, 2021 at 16:54

1 Answer 1

0

You need to import the path so that vue can figured it out where the file.

import image from "../assets/img/icon-facebook.svg"
export default {
 name: "social-media",
  data() {
    return {
       imgsource: image
    }
  },
};

or

require('../assets/img/icon-facebook.svg');

inline

 <img :src="require('../assets/img/icon-facebook.svg')"/>
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.