vue-slide
vue-slide copied to clipboard
图片列表通过接口获取导致报错
Uncaught TypeError: Cannot set property 'active' of undefined vue-slide.vue:234
暂时的解决办法如下,貌似还不是最好的方案:
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()
}
}