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

5次阅读

共计 359 个字符,预计需要花费 1 分钟才能阅读完成。

由于老项目用的 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);
    }
}

正文完
 0