I'm trying to replicate this, only with <script setup> tag which doesn't have this keyword.
Template (from code that I'm trying to replicate)
<swiper ref="swiper">
<swiper-slide></swiper-slide>
<swiper-slide></swiper-slide>
</swiper>
<a class="swiper-navigation is-previous" @click="swiper.slidePrev()"></a>
<a class="swiper-navigation is-next" @click="swiper.slideNext()"></a>
Script (from code that I'm trying to replicate)
computed: {
swiper() {
return this.$refs.swiper.swiper;
}
}
Tried to use getCurrentInstance() but for some reason getCurrentInstance().refs return empty object {} even though it's there when I do console.log(getCurrentInstance()).
My <script setup> component
<script setup lang="ts">
import { Swiper, SwiperSlide } from 'swiper/vue';
const swiper = // ???
const handleNextSlide = () => swiper.slideNext()
const handlePrevSlide = () => swiper.slidePrev()
</script>
<template>
<div>
<button @click="handlePrevSlide()">Prev</button>
<button @click="handleNextSlide()">Next</button>
<Swiper ref="swiper">
<SwiperSlide>1</SwiperSlide>
<SwiperSlide>2</SwiperSlide>
<SwiperSlide>3</SwiperSlide>
<SwiperSlide>4</SwiperSlide>
<SwiperSlide>5</SwiperSlide>
</Swiper>
</div>
</template>

script setupdoes not use syntax likecomputed: { swiper() {}}. How are you using that? You need to share more code.