question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Multiple instances of swiper using Nuxt / Vue

See original GitHub issue

BUG REPORT TEMPLATE

Vue version: “2.5.4” via Nuxt “^1.0.0-rc11” and “vue-awesome-swiper”: “^3.1.3”

Reproduction Link

//INDEX: Where I call a Swiper component

<template>
  <div class="home">
    <section>
      <h2 class="pageTitle container">Novedades</h2>
      <no-ssr><b-tabs class="homeTabNav" pills>
        <b-tab title="Por primera vez" active>
          <div class="homeSlider">
            <Carousel v-bind:json="$store.state.jsonA[0]"/>
          </div>
        </b-tab>
        <b-tab title="Están de vuelta">
          <div class="homeSlider">
            <Carousel v-bind:json="$store.state.jsonB[0]"/>
          </div>
        </b-tab>
      </b-tabs></no-ssr>
    </section>
  </div>
</template>

<script>
import Carousel from "~/components/Carousel.vue";
export default {
  components: {
    Carousel
  }
};
</script>


// Component: Where is located the swiper component with the binded data

<template>
  <div class="swiper-container">
    <div v-swiper:mySwipper="swiperOption">
      <div class="swiper-wrapper">
        <div class="swiper-slide" xxxxxxxxxxx >

          <router-link xxxxxxxxxxx>
          <div class="xxxxxxxxxxx">
            <h2 class="xxxxxxxxxxx" v-show="xxxxxxxxxxx">{{xxxxxxxxxxx}}</h2>
            <div class="xxxxxxxxxxx">{{xxxxxxxxxxx}}</div>
          </div>

        </div>
      </div>
      <div class="swiper-pagination"></div>
      <div class="swiper-button-prev"></div>
      <div class="swiper-button-next"></div>
    </div>
  </div>
</template>

<script>
import Vue from 'vue'
import 'swiper/dist/css/swiper.css'
if (process.browser) {
  const VueAwesomeSwiper = require('vue-awesome-swiper/dist/ssr')
  Vue.use(VueAwesomeSwiper)
}
export default {
  props: ["xxxxxxxxxxxxxxxxxxxxxx"],
  data(){
    return{
      swiperOption: {
        slidesPerView: 3,
        spaceBetween: 0,
        pagination: {
          el: '.swiper-pagination',
          clickable: true
        },
        navigation: {
          nextEl: '.swiper-button-next',
          prevEl: '.swiper-button-prev',
        }
      }
    }
  },
  asyncData(context) {
    // called every time before loading the component
    return {
      xxxxxx: "/xxxxxxxxxxxx/" + xxxxxxxxxxxx
    };
  }
};
</script>

Steps to reproduce

I need to call my swiper component in different instances, but only one swiper is loaded, the others just not works, the swipers are located in different tabs.

What is Expected?

Every instance of the component swiper has to be loaded and working by itself

What is actually happening?

Only one swiper works, the other just not.

Some screenshots:

##Working: captura de pantalla 2018-05-09 a la s 11 52 23

##Not Working: captura de pantalla 2018-05-09 a la s 11 52 40

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:14

github_iconTop GitHub Comments

19reactions
dllsystemcommented, Feb 20, 2019

v-swiper:mySwipper1=“swiperOption”

v-swiper:mySwipper2=“swiperOption”

6reactions
CHEWXcommented, Aug 13, 2019

You need a unique instance name.

<div class="slideshow" v-swiper="swiperOption" :instanceName="unique.id.here">

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using vue-awesome-swiper in a Nuxt Project
This article will take you through the step by step guide of setting up vue-awesome-swiper in a nuxt project, how to add custom...
Read more >
How can I have multiple "Swiper" slideshows on a single page
In my case, the issue was with using multiple auto-initialized instances while using Framework7 Core to update slide results based on the data...
Read more >
Swiper Vue.js Components
Swiper is the most modern free mobile touch slider with hardware accelerated transitions and amazing native behavior.
Read more >
Swiper 7 in Nuxt - StackBlitz
<div class="swiper mySwiper" ref="swiper">. <div class="swiper-wrapper">. <div class="swiper-slide">Slide 1</. div>. <div class="swiper-slide">Slide 2</.
Read more >
nuxt-vue-awesome-swiper-example - CodeSandbox
kyuwoo-choi / nuxt-vue-awesome-swiper-example / master. 2. Embed Fork Create Sandbox Sign in ... This Sandbox is in sync with master on GitHub.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found