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

I can't manipulate the instance with 'init:false' #157

Open
RemyAlbanes opened this issue Dec 16, 2024 · 3 comments
Open

I can't manipulate the instance with 'init:false' #157

RemyAlbanes opened this issue Dec 16, 2024 · 3 comments

Comments

@RemyAlbanes
Copy link

After several tries, I'm stuck on a problem:

I can't manipulate the instance after initializing my swiper with “init:false”.

If I go back to the examples, I can use my 'swiper.prev' and 'swiper.next' buttons in this example:
`

<script setup> // Create 10 slides const containerRef = ref(null) const slides = ref(Array.from({ length: 10 })) const swiper = useSwiper(containerRef) onMounted(() => { console.log(swiper.instance) }) </script> Slide {{ idx + 1 }}

<button @click="swiper.prev()">
Prev

<button @click="swiper.next()">
Next

<style lang="css"> swiper-slide { display: flex; justify-content: center; align-items: center; font-size: 18px; height: 20vh; font-size: 4rem; font-weight: bold; font-family: 'Roboto', sans-serif; } </style>

`

But they no longer work in this one:

`

<script setup> const containerRef = ref(null) const slides = ref(Array.from({ length: 10 })) const swiper = useSwiper(containerRef,{ slidesPerView:1 }) onMounted(() => { console.log(swiper.instance) }) </script> Slide {{ idx + 1 }}

<button @click="swiper.prev()">
Prev

<button @click="swiper.next()">
Next

<style lang="css"> swiper-slide { display: flex; justify-content: center; align-items: center; font-size: 18px; height: 20vh; font-size: 4rem; font-weight: bold; font-family: 'Roboto', sans-serif; } </style>

`

Is it a bug? Or am I doing something wrong?

@cpreston321
Copy link
Owner

@RemyAlbanes Can you supply a stackblitz example for me to debug?

Thanks!

@RemyAlbanes
Copy link
Author

@cpreston321
Copy link
Owner

@RemyAlbanes This actually might be related to this PR #140. I will have to double check the code, but this could be due to it returning the computed instance of the swiper, I will take a look here soon.

Thank you!

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