[Vuejs]-Load static assets with vue-cli 3.x

1👍

The images will need to be in the same directory or a child directory of the file in which you’re trying to access them (i.e. in the Components directory).

Can you also try to access the image via its URL <img src="http://localhost:8080/img/guyana-live-logo.png" />?

This should work, but you may not want to use it this way.

Another possibility you might be able to use is doing this:

<script>
import image from './img/slide-1.jpg'
...

Then in Vue data:

  data() {
    return {
      img: image,
    };

  },

Then in your HTML:

<img :src="image"/>

This solves issues when trying to access images when building with Parcel Bundler

Leave a comment