Home >Web Front-end >JS Tutorial >What should I do if dynamic loading of data always fails when sliding?
This time I will bring you what to do if the sliding of dynamically loaded data always fails. What should I do to solve the problem of dynamically loaded data sliding always failing?
Two solutions
1. Initialize swiper after loading the datasuccess: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 ='<p class="noCollect">' + resultdata.msg + '</p>';
}else{
for(var i in dataList){
var data = dataList[i];
html += '<p class="swiper-container artistp">'
+ '<p class="swiper-wrapper">'
+ '<p class="swiper-slide workp">'
+ '<p class="app_inlineBlock workPic">'
+ '<img class="picImg" src="'+ data.artistAvatar +'" />'
+ '</p>'+'<p class="app_inlineBlock workInfo">'
+ '<p class="artistName">' + data.artistName + '</p>'
+ '<p class="workName">' + data.artworkName + '</p>'
+ '<p class="workValue">'+ data.typeName +'/'+ data.width + '*' + data.height +'/' +data.createYear + '</p>'
+ '</p><p class="app_inlineBlockRight workPrice">'
+ '<p class="price">¥'+ data.marketPrice +'</p></p></p>'
+ '<p class="swiper-slide delBtn">删除</p></p></p>';
}
}
$("#list").append(html);
//swiper初始化
var swiper = new Swiper('.swiper-container', {
pagination: '.swiper-pagination',
slidesPerView: 'auto',
paginationClickable: true,
spaceBetween: 0
});
}
swiper1 = new Swiper('.swiper-container', {
initialSlide :0,
observer:true,//修改swiper自己或子元素时,自动初始化swiper
observeParents:true//修改swiper的父元素时,自动初始化swiper
});
I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!
Recommended reading:
How to change the status of radio using JS
##var foo = function () {} and function The difference between foo()
How to set bootstrap table to height percentage
The above is the detailed content of What should I do if dynamic loading of data always fails when sliding?. For more information, please follow other related articles on the PHP Chinese website!