swiper 分组切换_编程笔记

swiper 分组切换

2023-02-06 14:06:27  浏览:832  作者:保利尼奥
常见swiper分组代码
<div class="pro_right_con tab-con">
    {% for value in app('category').lists('product') %}
    <div class="pro_main tab-main">
        <div class="proSwiper swiper-cp{{loop.index}}">
            <div class="swiper-wrapper">
                {% for val in app('content').lists('product', value.cid, 10) %}
                <div class="slicon">
                    <a href="{{ val.url }}" title="{{ val.title }}">
                        <div class="slex"><h3>111111</h3></div>
                    </a>
                </div>
                {% endfor %}
            </div>
        </div>
        <script>
            /* 使用js分组,每2个.slick-con放到一个div里面 */
            jQuery(".swiper-cp{{loop.index}} .slicon").each(function(i){ jQuery(".swiper-cp{{loop.index}} .slicon").slice(i*2,i*2+2).wrapAll("<div class='swiper-slide'></div>");});

            var swiper = new Swiper(".swiper-cp{{loop.index}}", {
                slidesPerView: 3,
                spaceBetween: 60,
                autoplay:true,
                loop: false,
                breakpoints: {
                768: { //当屏幕宽度大于等于320
                    slidesPerView: 1,
                    spaceBetween: 10
                },
                992: { //当屏幕宽度大于等于768
                    slidesPerView: 2,
                    spaceBetween: 20
                },
                1366: { //当屏幕宽度大于等于1280
                    slidesPerView: 2,
                    spaceBetween: 30,
                    },
                },
            });
        </script>
       
    </div>
    {% endfor %}
</div>


上一篇:已经是第一篇

下一篇:swiper 鼠标移入切换

评论区

共 0 条评论
  • 这篇文章还没有收到评论,赶紧来抢沙发吧~

【随机内容】

返回顶部