Answer the question
In order to leave comments, you need to log in
How to link two vue-slick-carousel sliders?
I wanted to ask for help in setting up communication between two snipers made on vue-slick-carousel.
<div class="preview">
<VueSlickCarousel
ref="preview"
:asNavFor="$refs.miniPreview"
:focusOnSelect="true"
:fade="true"
:arrow="false">
<div class="preview-slide" v-for="image in images">
<img :src="image" alt="{{project.title}}">
</div>
</VueSlickCarousel>
</div>
<div class="mini-slider">
<VueSlickCarousel
ref="miniPreview"
:slidesToShow="1"
:variableWidth="true"
:focusOnSelect="true"
:arrow="true"
:centerMode="true">
<div class="mini-preview" v-for="image in images">
<img :src="image" alt="{{project.title}}">
</div>
<template #prevArrow>
<div class="btn-prev">
<i class="fas fa-chevron-left"></i>
</div>
</template>
<template #nextArrow>
<div class="btn-next">
<i class="fas fa-chevron-right"></i>
</div>
</template>
</VueSlickCarousel>
</div>
Answer the question
In order to leave comments, you need to log in
:asNavFor="$refs.miniPreview"
$refs
are only populated after the component has been rendered, and are not reactive. This is meant only as a workaround for directly manipulating descendants - you should avoid accessing$refs
from templates or computed properties.
mounted() {
this.$nextTick(this.$forceUpdate);
},
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question