zoukankan      html  css  js  c++  java
  • 遍历实例化swiper


    var list = $('.p04-s2 li');
    list.each(function (index) {
    new Swiper ($(this).find('.swiper-container'), {
    spaceBetween: 10,
    slidesPerView : 3,
    watchOverflow: true,
    centeredSlides : true,
    loop: true,
    breakpoints: {
    1500: {
    slidesPerView: 2
    },
    1200: {
    slidesPerView: 1
    }
    },
    pagination: {
    el: $(this).find('.swiper-pagination'),
    clickable :true
    },
    navigation: {
    prevEl: $(this).find('.prev-btn'),
    nextEl: $(this).find('.next-btn'),
    }
    });
    });

    如果是tab下遍历swiper

     
            function initSwiper($element) {
                new Swiper ($element.find('.swiper-container'), {
                    spaceBetween: 20,
                    slidesPerView : s1PerNum,
                    watchOverflow: true,
                    loopedSlides: 5,
                    loop: isLoop($element.find('.swiper-slide'), s1PerNum),
                    breakpoints: { 
                        1366: {
                            slidesPerView: 3
                        },
                        960: {
                            slidesPerView: 2
                        },
                        540: {
                            slidesPerView: 1
                        }
                    },
                    navigation: {
                        prevEl: $element.find('.prev'),
                        nextEl: $element.find('.next')
                    }
                }); 
            }
     
            $('.tab li').click(function() {
                $('.tab li').removeClass('current');
                $(this).addClass('current');
                var clickIndex = $(this).index();
                $currentLI = $('.text-slider > li').removeClass('active').eq(clickIndex).addClass('active');
                if (!$currentLI.data('initState')) {
                    initSwiper($currentLI);
                    $currentLI.data('initState', true);
                }
            }).eq(0).trigger('click'); 
  • 相关阅读:
    Unity3D 5.3 新版AssetBundle使用方案及策略
    解构C#游戏框架uFrame兼谈游戏架构设计
    漫谈C#编程语言在游戏领域的应用
    TDD在Unity3D游戏项目开发中的实践
    趣说游戏AI开发:曼哈顿街角的A*算法
    “为什么DirectX里表示三维坐标要建一个4*4的矩阵?”
    趣说游戏AI开发:对状态机的褒扬和批判
    使用TypeScript拓展你自己的VS Code!
    MVP社区巡讲-云端基础架构:12月5日北京站 12月12日上海站
    【转】Spring Boot干货系列:(一)优雅的入门篇
  • 原文地址:https://www.cnblogs.com/gduf/p/12021039.html
Copyright © 2011-2022 走看看