您好,登錄后才能下訂單哦!
兩種解決方法
1、數(shù)據(jù)加載后進(jìn)行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自己或子元素時(shí),自動(dòng)初始化swiper observeParents:true//修改swiper的父元素時(shí),自動(dòng)初始化swiper });
以上這篇swiper 解決動(dòng)態(tài)加載數(shù)據(jù)滑動(dòng)失效的問題就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持億速云。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。