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

length of undefined

Open Fabirm9 opened this issue 5 years ago • 12 comments

I have these errors, help please.

image

My code is: image

Fabirm9 avatar Mar 03 '20 22:03 Fabirm9

please share the issue with the reproducible demo.

kyuwoo-choi avatar Mar 04 '20 12:03 kyuwoo-choi

demo:

<template>
  <div>
    <vue-slick-carousel ref="slick" key="slick" v-bind="slickOptions">
      <div v-for="i in items" :key="i.id + '_' + Math.random()">
        {{ i.id }}
      </div>
    </vue-slick-carousel>
  </div>
</template>

<script>
import VueSlickCarousel from 'vue-slick-carousel'
import 'vue-slick-carousel/dist/vue-slick-carousel.css'
import 'vue-slick-carousel/dist/vue-slick-carousel-theme.css'

export default {
  layout: 'simple',
  name: 'Test',
  components: {
    VueSlickCarousel
  },

  data() {
    return {
      slickOptions: {
        autoplay: true,
        variableWidth: true,
        dots: true,
        swipeToSlide: true,
        arrows: false
      },
      items: []
    }
  },

  mounted() {
    const f = []
    for (let i = 0; i < 100; i++) {
      f.push({ id: i })
    }
    this.items = f
  }
}
</script>

The28AWG avatar Mar 09 '20 09:03 The28AWG

mounted method not need. =)

The28AWG avatar Mar 09 '20 09:03 The28AWG

its error with empty items/default slot

The28AWG avatar Mar 09 '20 09:03 The28AWG

yep.

<vue-slick-carousel v-bind="slickOptions"> </vue-slick-carousel>

TypeError: Cannot read property 'length' of undefined at VueComponent.slideCount (vue-slick-carousel.umd.js?a7ab:10656)

The28AWG avatar Mar 09 '20 09:03 The28AWG

Although the carousel is assumed to have children, It'll be better to handle the no child exception.

kyuwoo-choi avatar Mar 09 '20 13:03 kyuwoo-choi

It’s just that the content may load a bit later. Specify v-if as the content is missing or not yet loaded.

The28AWG avatar Mar 09 '20 13:03 The28AWG

Hi,

I have this problem too.

Do you have a plan to provide a fix for this?

Regards

fgoulhot avatar Mar 25 '20 08:03 fgoulhot

Hi, For the others, I got around the bug by adding an empty div in the slot.

fgoulhot avatar Apr 25 '20 20:04 fgoulhot

Adding v-if resolved the issue, as:

<VueSlickCarousel v-bind="settings" v-if='yourVariable.length'> ... </VueSlickCarousel>

hari03 avatar Jun 25 '20 11:06 hari03

same issue when try to use it on component

rolexta avatar Jul 13 '20 08:07 rolexta

It's strange, I experienced this on a nuxt.js app then I register the component(despite no need to do that), it solved the issue.

mcanvar avatar Mar 17 '21 21:03 mcanvar