您好,登錄后才能下訂單哦!
兩種解決方法
1、數據加載后進行swiper初始化
success:function(result){ var resultdata =eval("("+result+")"); if(resultdata.status == 1){ var dataList = resultdata.data; currentPage = resultdata.currentPage; pageCount = resultdata.pageCount; var html = ""; if(pageCount == 0){ html ='<div class="noCollect">' + resultdata.msg + '</div>'; }else{ for(var i in dataList){ var data = dataList[i]; html += '<div class="swiper-container artistDiv">' + '<div class="swiper-wrapper">' + '<div class="swiper-slide workDiv">' + '<div class="app_inlineBlock workPic">' + '<img class="picImg" src="'+ data.artistAvatar +'" />' + '</div>'+'<div class="app_inlineBlock workInfo">' + '<div class="artistName">' + data.artistName + '</div>' + '<div class="workName">' + data.artworkName + '</div>' + '<div class="workValue">'+ data.typeName +'/'+ data.width + '*' + data.height +'/' +data.createYear + '</div>' + '</div><div class="app_inlineBlockRight workPrice">' + '<div class="price">¥'+ data.marketPrice +'</div></div></div>' + '<div class="swiper-slide delBtn">刪除</div></div></div>'; } } $("#list").append(html); //swiper初始化 var swiper = new Swiper('.swiper-container', { pagination: '.swiper-pagination', slidesPerView: 'auto', paginationClickable: true, spaceBetween: 0 }); }
2、swiper初始化加兩行代碼
swiper1 = new Swiper('.swiper-container', { initialSlide :0, observer:true,//修改swiper自己或子元素時,自動初始化swiper observeParents:true//修改swiper的父元素時,自動初始化swiper });
以上這篇swiper 解決動態加載數據滑動失效的問題就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持億速云。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。