4

I am trying to add an image to the img-src="" attribute of b-carousel in BoostrapVue. The image is currently saved in the asset folder.

  <b-carousel-slide img-src="../assets/life.jpg">
        <h1>Hello world!</h1>
      </b-carousel-slide>

enter image description here

I have added Find below images of the result: enter image description here

I am certain the images are correctly saved in the right location: enter image description here

3
  • 1
    Check the network tab. It's probably not trying to load the image from where you think it is. Commented Oct 18, 2019 at 19:20
  • Are you positive that ../assets/life.jpg is the correct file location for the image? Commented Oct 18, 2019 at 19:24
  • @BLAKE I am certain that it is the correct file location. I have included an image to show the actual file structure Commented Oct 18, 2019 at 19:34

1 Answer 1

5

If using a loader with webpack (i.e. vue-loader, url-loader, etc), you need to ensure that the loader knows that img-src accepts a URL.

See the docs on information on how to tell the loaders to handle URL props on custom components: https://bootstrap-vue.js.org/docs/reference/images (specifically Vue Loader transformAssetUrls)

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

2 Comments

How do I modify this? Couldnt find vue.config.js in my project file
It might be in your webpack.config.js file or if using Nuxt.js in your nuxt.config.js.file. vue-loader.vuejs.org/guide/asset-url.html#asset-url-handling

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.