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'); 
  • 相关阅读:
    Java方法_数组
    Java语句
    C#死锁示例
    Sqlserver限制用户访问指定数据库
    Stream 和 byte[] 之间的转换
    ContentType
    IIS7多站点ssl配置及http自动跳转到https
    google map api key配置
    remote: Incorrect username or password ( access token ) fatal: Authentication failed for
    IIS 404设置
  • 原文地址:https://www.cnblogs.com/gduf/p/12021039.html
Copyright © 2011-2022 走看看