zoukankan      html  css  js  c++  java
  • 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 
    });
    

      

  • 相关阅读:
    独立开发unity2d游戏的问答群
    使用闭包和lambda解决问题与常规方式解决问题的对比。
    说《深渊》
    AS3项目基础框架搭建分享robotlegs2 + starling1.3 + feathers1.1
    ArrayList源码学习
    在springMVC的controller中获取request,response对象的一个方法
    postgresql存储过程
    RabbitMq笔记
    dubbo学习笔记
    修改数据库的最大连接数
  • 原文地址:https://www.cnblogs.com/agansj/p/9054094.html
Copyright © 2011-2022 走看看