百度ecahrts和swiper一起使用,loop复制slide导致图表不展示的问题解决

gjcxywwx 2019-11-04

由于老项目用的swiper3,所以这里贴出来的是swiper3的配置项,swiper4的参照下面的稍作修改即可(原理就是通过回调自己手动控制)

autoplay: 0,
loop: false,
onInit: swiper => {
    setTimeout(() => {
        swiper.slideNext();
    }, 1500);
},
onSlideChangeEnd: swiper => {
    if (swiper.activeIndex === 1) {
        let dom = swiper.slides[0];
        swiper.removeSlide(0);
        swiper.appendSlide(dom);
        swiper.activeIndex = 0;
        swiper.update();
        setTimeout(() => {
            swiper.slideNext();
        }, 1500);
    }
}

相关推荐