Idangero Sniper:添加一张幻灯片

时间:2019-01-06 14:47:44

标签: javascript jquery

我正在尝试在ajax调用中添加一个懒惰的加载幻灯片,但不知道为什么图像没有显示

mySwiper.appendSlide(['<div class="swiper-slide"><img data-src="blabla.jpg" class="swiper-lazy"></div>']);
setTimeout(function () { mySwiper.update(); },500);
mySwiper.lazy.load( mySwiper.slides.length -1 );
mySwiper.slideTo(mySwiper.slides.length -1,500,false);

1 个答案:

答案 0 :(得分:0)

改为将其添加到DOM

$(".swiper-wrapper div:last-child").after('<div class="swiper-slide"><img data-src="blabla.jpg" class="swiper-lazy"></div>');
setTimeout(function () { mySwiper.update(); },500);
mySwiper.slideTo(mySwiper.slides.length -1,500,false);