Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

326
Views
Example of SwiperJs slider with Vue3 option API

Can someone show me an example of SwiperJs slider, using Vue3 option api, not composition Api?
I mean pure javascript with template inside the html.

like

<div>
  <div slider container>
      <div vfor>
      </div>
  </div>

</div>
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You can use something like this:

<template>
  <div
    :id="id"
    class="swiper-container"
  >
    <div
      class="swiper-wrapper"
      @click="$emit('click')"
    >
      <!-- swipe right template -->
      <template v-if="direction === 'right'">
        <v-list-item class="swiper-slide" />
        <v-list-item class="swiper-slide">
          <v-list-item-content>
            <slot />
          </v-list-item-content>
        </v-list-item>
      </template>

      <!-- swipe left template -->
      <template v-if="direction === 'left'">
        <v-list-item class="swiper-slide">
          <v-list-item-content>
            <slot />
          </v-list-item-content>
        </v-list-item>
        <v-list-item class="swiper-slide" />
      </template>
    </div>
  </div>
</template>

<script>
import 'swiper/dist/css/swiper.min.css';
import { Swiper } from 'swiper/dist/js/swiper.esm.js';

export default
{
  props:
  {
    id:
      {
        type: [String, Number],
        required: true
      },
    direction:
    {
      type: String,
      default: 'right',
      validator: value => ['right', 'left'].indexOf(value) !== -1
    }
  },
  mounted () {
    const self = this;
    const el = '#' + this.id;
    const direction = this.direction;

    // Initialize Swiper
    const swiper = new Swiper(el, {
      initialSlide: this.direction === 'left' ? 0 : 1,
      resistanceRatio: 0,
      speed: 150,
      observer: true,
      observeParents: true,
    });

    // Event will be fired after transition
    swiper.on('transitionEnd', function () {
      const activeIndex = this.activeIndex;
      if ((direction === 'right' && activeIndex === 0) || (direction === 'left' && activeIndex === 1)) {
        self.$emit('swiped');
        // Destroy slider instance and detach all events listeners
        this.destroy();
      }
    });
  }
};
</script>
about 4 years ago · Juan Pablo Isaza Report

0

Use can use like this

<template>
 
 <swiper
    :slides-per-view="4"
    :space-between="30"
    @swiper="onSwiper"
    @slideChange="onSlideChange"
    class="default-slider"
  >
    <swiper-slide v-for="item in items" :key="item">
        <img :src="item" />
    </swiper-slide>
  </swiper>
</template>

<script>
import { Swiper, SwiperSlide } from 'swiper/vue';

export default {
    components: {
      Swiper,
      SwiperSlide,
    },
    data() {
        return {
            items: ['1.jpg','2.jpg','3.jpg','4.jpg','5.jpg','6.jpg','7.jpg']
        }
    }
}
</script>
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!