ajax请求+swiper轮播图报错如何解决
2017-08-03 本文已影响365人
倩倩psyche
![Uploading QQ截图20170803163836_543744.png . . .]
问题:在使用swiper插件的时候,如果图片是从网络请求的,在页面刷新的时候,轮播图出错,不会轮播。
解决方案:
![](https://img.haomeiwen.com/i1783112/479ce672885e483c.png)
var mySwiper = new Swiper ('.swiper-container', {
direction: 'horizontal',
autoplay:3000,
// 如果需要分页器
pagination: '.swiper-pagination',
//添加这两个属性!!!!!!!!!
observer:true,//修改swiper自己或子元素时,自动初始化swiper
observeParents:true,//修改swiper的父元素时,自动初始化swiper
});