vue-slide icon indicating copy to clipboard operation
vue-slide copied to clipboard

图片列表通过接口获取导致报错

Open billwing opened this issue 7 years ago • 1 comments

Uncaught TypeError: Cannot set property 'active' of undefined vue-slide.vue:234

billwing avatar Dec 10 '16 07:12 billwing

暂时的解决办法如下,貌似还不是最好的方案:

init ()  {
    ...
    this.initPages()
    ...
},

initPages () {
    this.swiper.count = this.$el.getElementsByClassName('rd-swipe-item').length

    if (this.options.pagination) {
        this.pagination = Array.from({length: this.swiper.count}).map((item, index) => {
            return {
                index: index,
                active: index === 0
            }
        })
    }
},

setPaginationActive (index) {
    this.pagination.forEach(item => item.active = false)
    if (this.pagination[index]) {
        this.pagination[index].active = true
    } else {
        this.initPages()
    }
}

billwing avatar Dec 10 '16 08:12 billwing