swiper4初始化/swiper-init/data-swiper

用data属性初始化swiper

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Swiper</title>
    <link href="https://cdn.bootcss.com/Swiper/4.0.6/css/swiper.css" rel="stylesheet">
    <script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.js"></script>
    <script src="https://cdn.bootcss.com/Swiper/4.0.6/js/swiper.js"></script>

    <style>
        html, body {
            position: relative;
            height: 100%;
        }

        body {
            background: #eee;
            font-family: Helvetica Neue, Helvetica, Arial, sans-serif;
            font-size: 14px;
            color: #000;
            margin: 0;
            padding: 0;
        }

        .swiper-container {
            width: 100%;
            height: 100%;
        }

        .swiper-slide {
            text-align: center;
            font-size: 18px;
            background: #fff;

            /* Center slide text vertically */
            display: -webkit-box;
            display: -ms-flexbox;
            display: -webkit-flex;
            display: flex;
            -webkit-box-pack: center;
            -ms-flex-pack: center;
            -webkit-justify-content: center;
            justify-content: center;
            -webkit-box-align: center;
            -ms-flex-align: center;
            -webkit-align-items: center;
            align-items: center;
        }

        .box {
            display: block;
            height: 500px;
        }

        .bg-gray {
            background: #eaeaea;
        }
    </style>
</head>
<body>

<div class="box">
    <div class="swiper-container swiper-init"
         data-swiper="{slideToClickedSlide:false,autoplay:false,slidesPerView:2,spaceBetween:10,breakpoints:{992:{slidesPerView:1}}}">
        <div class="swiper-wrapper">
            <div class="swiper-slide bg-gray">
                <div class="swiper-container swiper-init" data-swiper="{autoplay:false,slidesPerView:2,spaceBetween:10,direction:'vertical',mousewheel:true,}">
                <div class="swiper-wrapper">
                    <div class="swiper-slide">bbb 1</div>
                    <div class="swiper-slide">bbb 2</div>
                    <div class="swiper-slide">bbb 3</div>
                </div>
                <div class="swiper-pagination"></div>
            </div></div>
            <div class="swiper-slide">aaa 2</div>
            <div class="swiper-slide">aaa 3</div>
            <div class="swiper-slide">aaa 4</div>
            <div class="swiper-slide">aaa 5</div>
        </div>
        <div class="swiper-pagination"></div>
        <div class="swiper-button-prev"></div>
        <div class="swiper-button-next"></div>
    </div>
</div>

<script>
    $(function () {
        $('.swiper-container.swiper-init').each(function () {
            var $swiper = $(this);
            var defaults = {
                navigation: {
                    prevEl: $swiper.children('.swiper-button-prev')[0],
                    nextEl: $swiper.children('.swiper-button-next')[0],
                },
                pagination: {
                    el: $swiper.children('.swiper-pagination')[0],
                    clickable: true,
                },
                autoplay: {
                    disableOnInteraction: false,
                },
                /*slideToClickedSlide: true,*/
                /*centeredSlides : true,*/
                setWrapperSize: true,
                observer: true,
                observeParents: true,
                loop: true,
            };
            var options = (new Function('return ' + $swiper.data('swiper')))();
            var settings = $.extend({}, defaults, options);
            var swiper = new Swiper(this, settings);
            swiper.on('resize', function () {
                swiper.update();
            });
            /*if (!!settings.loop && swiper.slides.length <= 3) {
                swiper.destroy();
            }*/
        })
    });
</script>
</body>
</html>

 

转载于:https://www.cnblogs.com/stumpx/p/7942768.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
引用:npm ERR! 404 Not Found - GET https://registry.npmmirror.com/@vue/vue-loader-v15 - [NOT_FOUND] @vue/vue-loader-v15 not found vue 安装npm i element-ui -S 等 组件 报错 npm ERR! code E404 npm ERR! 404 Not Found - GET https://registry.npmmirror.com/@vue/vue-loader-v15 - [NOT_FOUND] @vue/vue-loader-v15 not found npm ERR! 404 npm ERR! 404 '@vue/vue-loader-v15@15.10.0' is not in the npm registry. npm ERR! 404 You should bug the author to publish it (or use the name yourself!) npm ERR! 404 It was specified as a dependency of '@vue/cli-service' npm ERR! 404 npm ERR! 404 Note that you can also install from a npm ERR! 404 tarball, folder, http url, or git url. 根据引用的内容,这个错误是由于找不到vue-awesome-swiper的tarball数据所导致的。vue-awesome-swiper的tarball数据位于http://172.168.251.67:4873/vue-awesome-swiper/-/vue-awesome-swiper-3.1.3.tgz。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [npm install -g cnpm --registry=https://registry.npm.taobao.org报错](https://blog.csdn.net/qq_36853469/article/details/99900961)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [ist的matlab代码-gitlab-uberspace-tutorial:如何在https://uberspace.de上安装GitLab](https://download.csdn.net/download/weixin_38543120/19078868)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [ 404 Not Found - GET https://registry.npmmirror.com/@vue%2fvue-loader-v15 - [NOT_FOUND] @vue](https://blog.csdn.net/qq_51307593/article/details/127484795)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值