Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swiper breaks when I change the localization #92

Open
ilgarabdullazade opened this issue Sep 17, 2023 · 1 comment
Open

Swiper breaks when I change the localization #92

ilgarabdullazade opened this issue Sep 17, 2023 · 1 comment

Comments

@ilgarabdullazade
Copy link

ilgarabdullazade commented Sep 17, 2023

image

I've encountered an issue where the Swiper component breaks when I attempt to change the localization (language or regional settings) on my project. This issue is causing functionality problems and unexpected behavior in my application.

import { ApiEndpoints } from '~/utils/apiEndpoints'

const { data: testimonials, pending } = await useMyFetch<Testimonial[]>(
  ApiEndpoints.TESTIMONIALS,
  {
    server: false,
  }
)
const isMobile = useMediaQuery('not all and (min-width: 1024px)')

const onSwiperInit = (swiper: any) => {
  const { initDOM } = useAfterOutIn(() => {
    swiper.pagination.enable()
  })
  initDOM()
}
</script>

<template>
  <SiteSkeletonSection v-if="pending" :items="isMobile ? 1 : 2" />
  <section v-else class="testimonials">
    <div v-if="testimonials?.length" class="testimonials__wrapper">
      <SiteTitle class="testimonials__title">{{
        $t('testimonials.title')
      }}</SiteTitle>
      <div class="testimonials__body">
        <Swiper
          @swiper="onSwiperInit"
          class="testimonials__swiper"
          :modules="[SwiperAutoplay, SwiperPagination]"
          :slides-per-view="1"
          :pagination="{
            el: '.testimonials__pagination',
            clickable: true,
          }"
          :breakpoints="{
            '1024': {
              slidesPerView: 2,
              spaceBetween: 10,
            },
          }"
        >
          <SwiperSlide
            class="testimonials__slide"
            v-for="testimonial in testimonials"
            :key="testimonial.full_name"
          >
            <HomeTestimonialsItem
              :testimonial="testimonial"
              class="testimonials__item"
            />
          </SwiperSlide>
        </Swiper>
        <div
          class="testimonials__pagination swiper-pagination swiper-pagination-line"
        ></div>
      </div>
    </div>
  </section>
</template>```
@hizbul25
Copy link

@ilgarabdullazade did you get any solution? I am having same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants