Swiper: Navigation does not work when import Swiper as module

Created on 23 Jul 2020  路  1Comment  路  Source: nolimits4web/swiper

This is a (multiple allowed):

  • [x] bug
  • [ ] enhancement
  • [ ] feature-discussion (RFC)

What you did

  1. Navigation does not work when I tried this code
import Swiper from 'swiper';

var swiper = new Swiper('.swiper-container', {
  navigation: {
    nextEl: '.swiper-button-next',
    prevEl: '.swiper-button-prev',
  },
});
  1. Navigation works when I tried this code
import Swiper from 'swiper/swiper-bundle'

var swiper = new Swiper('.swiper-container', {
  navigation: {
    nextEl: '.swiper-button-next',
    prevEl: '.swiper-button-prev',
  },
});

Please see live demo: https://stackblitz.com/edit/swiper-demo-2-navigation-xozcpb?file=index.js

Expected Behavior

Navigation should work when click in both case 1 and 2.

Actual Behavior

Navigation does NOT work in case 1.

Before you open an issue, please check if a similar issue already exists or has been closed before.

Yes, #3703 exists, but it is locked so I can not add comment to it.

Most helpful comment

Please see document:
https://swiperjs.com/api/#custom-build

import { Swiper, Navigation } from 'swiper';

Swiper.use([Navigation]);

var swiper = new Swiper('.swiper-container', {
  navigation: {
    nextEl: '.swiper-button-next',
    prevEl: '.swiper-button-prev',
  },
});

It works now.

>All comments

Please see document:
https://swiperjs.com/api/#custom-build

import { Swiper, Navigation } from 'swiper';

Swiper.use([Navigation]);

var swiper = new Swiper('.swiper-container', {
  navigation: {
    nextEl: '.swiper-button-next',
    prevEl: '.swiper-button-prev',
  },
});

It works now.

Was this page helpful?
0 / 5 - 0 ratings