Vue 2 Wrapper for Slick Carousel

1.2.0 · abandoned · verified Sun Apr 19

vue-slick is a component library that provides a Vue 2 wrapper for the popular jQuery-based Slick Carousel. It allows developers to integrate the feature-rich Slick carousel into their Vue 2 applications with a component-based API. The package is currently at version 1.2.0 and has been explicitly declared as no longer actively maintained by its primary contributor, indicating an abandoned status. It differentiates itself by offering a Vue-native syntax for controlling Slick, including prop-based options, method calls via refs, and event listeners. However, its core reliance on `slick-carousel` and `jQuery` introduces complexities, particularly concerning dependency management and potential version conflicts, which are highlighted in its documentation. Its support is strictly limited to Vue 2 environments.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to import, register, and use the `Slick` component in a Vue 2 application. It shows how to pass options via props, control the carousel programmatically using methods accessed via refs, and listen to events.

import Vue from 'vue';
import Slick from 'vue-slick';
import 'slick-carousel/slick/slick.css';

new Vue({
    el: '#app',
    components: { Slick },

    data() {
        return {
            slickOptions: {
                slidesToShow: 3,
                dots: true,
                infinite: true,
                speed: 500,
                // Any other options that can be got from plugin documentation
            },
            slides: [
                'http://placehold.it/2000x1000?text=Slide%201',
                'http://placehold.it/2000x1000?text=Slide%202',
                'http://placehold.it/2000x1000?text=Slide%203',
                'http://placehold.it/2000x1000?text=Slide%204',
                'http://placehold.it/2000x1000?text=Slide%205'
            ]
        };
    },

    methods: {
        next() {
            this.$refs.slick.next();
        },

        prev() {
            this.$refs.slick.prev();
        },

        reInit() {
            // Helpful if you have to deal with v-for to update dynamic lists
            this.$nextTick(() => {
                this.$refs.slick.reSlick();
            });
        },

        handleAfterChange(event, slick, currentSlide) {
            console.log('After change:', currentSlide);
        }
    },

    template: `
        <div>
            <button @click="prev">Previous</button>
            <button @click="next">Next</button>
            <button @click="reInit">Re-init</button>
            <slick ref="slick" :options="slickOptions" @afterChange="handleAfterChange">
                <a v-for="(src, index) in slides" :key="index" :href="src">
                    <img :src="src" alt="Slide Image" />
                </a>
            </slick>
        </div>
    `
});

view raw JSON →