vue-slick-carousel icon indicating copy to clipboard operation
vue-slick-carousel copied to clipboard

How do you reset or update the slider?

Open joannesalfa opened this issue 4 years ago • 4 comments

Why is there an event "reInit"? there is no reset or update method!

joannesalfa avatar Feb 02 '21 15:02 joannesalfa

You can force Vue to rerender the carousel when the content of the slider change. To do it you will need to watch the change of the content.

...
<VueSlickCarousel
      v-bind="settings"
      :key="carouselKey"
    >
         <custom-component
               v-for="(item, index) in services"
         />
</VueSlickCarousel>
...
  watch: {
    services() {
      this.forceRerender()
    },
  },
  methods: {
    forceRerender() {
      this.carouselKey += 1
    },
  },
...

danieljindev avatar Jun 29 '21 17:06 danieljindev

Hi, i got this message after change the key and try to change slide

Error in v-on handler: "TypeError: Cannot read property 'goTo' of undefined"

refers to line: this.$refs.innerSlider.goTo(slide, dontAnimate);

Note: this cause error only when you have 2 carousel asNavFor and update the :key value

MemoRodMx avatar Sep 05 '21 15:09 MemoRodMx

@MemoRodMx Hi, how did you solve the problem with Error in v-on handler: "TypeError: Cannot read property 'goTo' of undefined" I have two carousel with asNavFor and after change data carousel return this error. Thanks.

minoo221 avatar Apr 26 '22 07:04 minoo221