Closed avpuchkova closed 3 months ago
This should help with your issue: https://github.com/ismail9k/vue3-carousel/issues/104
I tried all the tips from here. Now my files look like this: //App.vue
<template>
<div class="page-container container">
<Carousel :items-to-show="2" :breakpoints="breakpoints">
<Slide v-for="slide in 10" :key="slide">
<div class="carousel__item">{{ slide }}</div>
</Slide>
<template #addons>
<navigation />
<pagination />
</template>
</Carousel>
</div>
</template>
<script>
export default defineComponent({
name: 'PageName',
data() {
return {
settings: {
itemsToShow: 3,
snapAlign: 'center',
},
breakpoints: {
// 1024 and up
1024: {
itemsToShow: 3,
snapAlign: 'start',
},
// 1920 and up
1920: {
itemsToShow: 3.25,
snapAlign: 'start',
},
},
}
},
mounted() {
setTimeout(() => {
this.initialSlide = 0
if (this.$refs.slider) {
this.$refs.slider.restartCarousel()
}
slider.value.updateSlideWidth();
}, 50)
}
})
</script>
// nuxt.config.ts
export default defineNuxtConfig({
devtools: { enabled: true },
...,
modules: [
'vue3-carousel-nuxt'
]
})
//plugins -> vue3-carousel.client.js
import "vue3-carousel/dist/carousel.css";
import { Carousel, Slide, Pagination, Navigation } from "vue3-carousel";
export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.vueApp.component("Carousel", Carousel);
nuxtApp.vueApp.component("Slide", Slide);
nuxtApp.vueApp.component("Pagination", Pagination);
nuxtApp.vueApp.component("Navigation", Navigation);
});
Carousel is rendered. But breakpoints, Navigation and Pagination do not work.
If i wrap Carousel with <ClientOnly> ... </ClientOnly>
- it is not rendered at all
@avpuchkova You should not need plugins/vue3-carousel.client.js
, that's what the module is doing for you.
Resolved
Resolved
@avpuchkova , how did you solve the issue? In my case the carousel button is not showing.
@shadman-ahmed-bs23 I had bootstrap import issue. It blocked carousel render.
Navigation does not work in Nuxt 3 // package.json
// nuxt.config.ts
//App.vue
Next and Prev buttons do not work. What is wrong with my code?