Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
billwing opened this issue Dec 10, 2016 · 1 comment
Open

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

billwing opened this issue Dec 10, 2016 · 1 comment

Comments

@billwing
Copy link

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

@billwing
Copy link
Author

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

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()
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant