-1

i've installed swiper js with importmap:require swiper in symfony. it download a umd version of the package in the vendor/

Note: i use it in a stimulus controller

We cannot import Swiper from "swiper" because importmap install the umd version.

I've tried using it with const Swiper = window.Swiper; but it is undefined

import { Controller } from "@hotwired/stimulus";
import "swiper";

export default class extends Controller {
    connect() {
        const Swiper = window.Swiper;
        this.swiper = new Swiper('.swiper', {
            pagination: {
                el: '.swiper-pagination',
            },
            navigation: {
                nextEl: '.swiper-button-next',
                prevEl: '.swiper-button-prev',
            }
        });
    }
}

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.