Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Bagmaz's avatar
Level 22

LightGallery.js not working on v-for

Template:

<template>
    <div ref="lightgallery">
        <div v-for="image in images">
            <a class="lg-selector" :href="image">
                <img :src="image" class="img-fluid rounded">
            </a>
        </div>
    </div>
</template>

Script:

<script>
import 'lightgallery.js';
import 'lg-thumbnail.js';
import 'lg-fullscreen.js';
import 'lg-autoplay.js';
import 'lg-rotate.js';
import 'lg-zoom.js';
import 'lightgallery.js/dist/css/lightgallery.css';

export default {
    name: "LightGallery",

    props: ['images'],

    mounted() {
        window.lightGallery(this.$refs.lightgallery, {
            download: false,
            selector: '.lg-selector',
        });
    }
}
</script>
0 likes
0 replies

Please or to participate in this conversation.