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.

Looping custom component inside swiper-slide not rendering content but renders structure

See original GitHub issue

Looping custom component inside swiper-slide not rendering content but it renders the structure and swiper swiping works.

It works if I remove the swiper-slide around the component I wanted into the slide. But I think the library is not meant to be used without the swiper-slide correct me if I am wrong?

Also the directive for the library is not working!! So I cannot make my own structure.

This is what is going on:

Screenshot 2019-03-22 at 16 11 48
<template>
  <swiper
    ref="productSlider"
    :options="swiperOptions"
    class="product-slider"
    @slideChange="onSlideChange"
  >
    <swiper-slide
      v-for="item in items"
      :key="item.id"
    >
      <product-slide :item="item" />
    </swiper-slide>
    <div
      slot="pagination"
      class="product-slider__pagination"
    />
  </swiper>
</template>
<script>
import 'swiper/dist/css/swiper.css';

import { swiper, swiperSlide } from 'vue-awesome-swiper';
import ProductSlide from './ProductSlide.vue';


export default {
  name: 'ProductSlider',

  components: {
    swiper,
    swiperSlide,
    ProductSlide,
  },

  props: {
    items: {
      type: Array,
      default: () => [],
      required: true,
    },
  },
  data() {
    const self = this;
    return {
      isQuickviewEnabled: false,
      swiperOptions: {
        direction: 'vertical',
        loopedSlides: 1,
        spaceBetween: 30,
        slidesPerView: 1,
        effect: 'fade',
        loop: true,
        mousewheel: {
          invert: false,
        },
        // autoHeight: true,
        pagination: {
          el: '.product-slider__pagination',
          clickable: true,
          dynamicBullets: true,
          dynamicMainBullets: 1,
        },
      },
    };
  },
  computed: {
    swiper() {
      return this.$refs.productSlider.swiper;
    },
  },
  watch: {
    items(newValue, oldValue) {
      // if (this.swiper) {
      //   console.log(this.items);
      //   this.$nextTick(() => {
      //     this.swiper.loopDestroy();
      //     this.swiper.loopCreate();
      //   });
      // }
    },
  },
  methods: {
    onSlideChange() {
      console.log('Slide did change');
    },
  }
};
</script>

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:7
  • Comments:5

github_iconTop GitHub Comments

5reactions
artforteam2018commented, May 19, 2019

i added this to swiper config and it works

on: {
    slideChange: function () {
        if (this.isEnd) {
            this.loopDestroy();
            this.loopCreate();
         }
        if (this.isBeginning) {
             this.loopDestroy();
             this.loopCreate();
         }
    }
},
0reactions
mohitnagarrocommented, Feb 16, 2022

@artforteam2015 Solution worked for me but I cannot perform any event on custom component.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Swiper.js SwiperSlide render props not working properly with ...
I'm kinda stucked into a problem where isPrev and isNext SwiperSlide render props are not working correctly in a Swiper with loop prop...
Read more >
Swiper Changelog
paginationCustomRender(swiper, current, total) - custom function to render "custom" type pagination. New lazyLoadingInPrevNextAmount parameter allows to lazy ...
Read more >
Safari Technology Preview Release Notes - Apple Developer
Safari Technology Preview Release Notes. Release 160. Note: Shared Tab Groups and syncing for Tab Groups, Website Settings, and Web Extensions are not...
Read more >
React Swiper.js Slider - DEV Community ‍ ‍
Introduction In fact, today's article is devoted not only to how to make a specific slider, which... Tagged with react, javascript, tutorial ...
Read more >
Building modern sliders with HTML, CSS, and Swiper
Containers, or the boxes that house the slider components ... HTML markup to structure our project web page, layout, and its contents are ......
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