美文网首页
单页面插入两个Swiper

单页面插入两个Swiper

作者: 苹果咏 | 来源:发表于2018-07-18 16:52 被阅读0次
var mySwiper = new Swiper('.pcduan .swiper-container',{
    pagination : '.swiper-p1',
    autoplay : 7000,//可选选项,自动滑动
    speed:1000,//滑动时间
    loop : true,//可选选项,开启循环
    autoplayDisableOnInteraction : false,//用户操作swiper之后,是否禁止autoplay。默认为true:停止。
    paginationClickable :true,//分页器气切换
    grabCursor : true, //光标在Swiper上时成手掌状
    paginationClickable: true, // 定位到目标动画
    keyboardControl : true,//键盘控制
    //mousewheelControl : true,//滑鼠标滑轮控制
    prevButton:'.swiper-button-prev',
    nextButton:'.swiper-button-next',
  })



var mySwiper2 = new Swiper('.phoneduan .swiper-container',{
    pagination : '.swiper-p2',
    autoplay : 7000,//可选选项,自动滑动
    speed:1000,//滑动时间
    loop : true,//可选选项,开启循环
    autoplayDisableOnInteraction : false,//用户操作swiper之后,是否禁止autoplay。默认为true:停止。
    paginationClickable :true,//分页器气切换
    grabCursor : true, //光标在Swiper上时成手掌状
    paginationClickable: true, // 定位到目标动画
    keyboardControl : true,//键盘控制
    //mousewheelControl : true,//滑鼠标滑轮控制
  })

用父级CSS来区分,pagination重新写一个swiper-p1的css区分

//第一个
<div class="swiper-pagination swiper-p1 swiper-pagination-white swiper-pagination-clickable swiper-pagination-bullets">

//第二个
<div class="swiper-pagination swiper-p2 swiper-pagination-white swiper-pagination-clickable swiper-pagination-bullets">

这样轮播的光点也可以正常运行了

相关文章

网友评论

      本文标题:单页面插入两个Swiper

      本文链接:https://www.haomeiwen.com/subject/wtfapftx.html