How can I get the current index?
Can you add a function to return the current index?
Did you find out how to get or set the index?
<carousel ref="carousel">
...
</carousel>
computed: {
currentIndex: {
cache: false,
get() {
return this.$refs.carousel ? this.$refs.carousel.currentPage : 0;
}
}
}
<carousel ref="carousel" :perPage="1" :perPageCustom="[[320,1],[480,1],[960,1]]" :paginationEnabled="false" :navigationEnabled="true" >
<slide v-for="content in contens">
...
</slide>
</carosel>
computed: {
...mapGetters({...}),
currentIndex: {
get () {
return this.$refs.carousel ? this.$refs.carousel.currentPage : 0
}
}
}
Getting currentindex 0 for all slides
try to add;
cache: false
computed: {
...mapGetters({...}),
currentIndex: {
cache: false,
get () {
return this.$refs.carousel ? this.$refs.carousel.currentPage : 0
}
}
}
No luck :(
this.$refs.carousel is undefined
In your template
<carousel v-on:pageChange="pageChange">...</carousel>
In your script
methods: {
pageChange(i){
console.log('current Index', i);
},
}
Note: It fired when you change current page (by navigation or pagination)
@hhlingyoko, please, close this issue
Most helpful comment
In your template
<carousel v-on:pageChange="pageChange">...</carousel>In your script
methods: { pageChange(i){ console.log('current Index', i); }, }Note: It fired when you change current page (by navigation or pagination)