我在cordova和jquery项目上工作。 我使用idangero的 Swiper 作为幻灯片。
当我添加新幻灯片并尝试显示它们时,会出现我的问题。
Jquery代码:
if(row.pictures != ''){
var num_slide = mySwiper.slides.length;
console.log("[slidecontent ] "+slidecontent);
mySwiper.appendSlide([slidecontent]);
for (var i = 0; i < num_slide; i++) {
mySwiper.removeSlide(0);
}
mySwiper.update();
}
slidecontent 控制台日志显示:
[slidecontent ] '<div class="swiper-slide"><img src="..."></div>',
'<div class="swiper-slide"><img src="..."></div>',
'<div class="swiper-slide"><img src="..."></div>'
但它显示: HTML code
<div class="swiper-container swiper-container-horizontal">
<div class="swiper-wrapper" style="transform: translate3d(0px, 0px, 0px); -webkit-transform: translate3d(0px, 0px, 0px); transition: 0ms; -webkit-transition: 0ms;">
<div class="swiper-slide swiper-slide-duplicate swiper-slide-active" data-swiper-slide-index="0">
<img src="..."></div>
'',
'',
'<div class="swiper-slide swiper-slide-next" data-swiper-slide-index="0"><img src="..."></div>'
<div class="swiper-slide swiper-slide-duplicate" data-swiper-slide-index="0">
<img src="..."></div>
</div>
</div>
问题来自update()方法,我该如何解决这个问题?
答案 0 :(得分:0)
之前我遇到过这个,我所做的就是摧毁旧的并初始化更新的swiper。