pexea12 / vue-image-lightbox

A Vue component to display an image gallery lightbox
347 stars 80 forks source link

How to load images using require (as needed by vue.js) #52

Closed TheDistantSun closed 5 years ago

TheDistantSun commented 5 years ago

Not a bug or issue, but a question on usage (my apologizes in advance if this is not the right location to ask questions for vue-image-lightbox). I really want to use vue-image-lightbox. How to use 'require' to load .jpg images as needed by Vue.js?

For example (this will show images on page):

          <img
            v-lazy="require(`@/img/${image.src}`)"
            style="height: 100px"
            @click="openGallery(index)"
          >

However, when clicking on an image Lightbox comes up, but images are broken.

Question: How can 'require' be set for the .jpg images for/within (so when an images is clicked it will show as expected. Currently images are broken.)?

Thanks much for this tool, and your time.

pexea12 commented 5 years ago

You can just insert your image's link. I don't think it is necessary to use require here

<img
v-lazy="image.src"
style="height: 100px"
@click="openGallery(index)"
>