微信小程序实现带缩略图轮播效果


Posted in Javascript onNovember 04, 2018

本文实例为大家分享了微信小程序实现实现轮播效果展示的具体代码,供大家参考,具体内容如下

wxml:

<view id="content">
 <!--banner-->
 <view class="recommend">
  <view class="swiper-container">
   <swiper autoplay="auto" interval="5000" duration="500" current="{{swiperCurrent}}" circular="{{circular}}" bindchange="swiperChange" class="swiper">
    <block wx:for="{{slider}}" wx:key="unique">
     <swiper-item data-id="{{item.id}}" data-url="{{item.linkUrl}}" class="dot{{index == swiperCurrent ? ' active' : ''}}" bindtap="chuangEvents" id="{{index}}">
      <image src="{{item.picUrl}}" class="img"></image>
      <span>{{item.index+1}}</span>
     </swiper-item>
    </block>
   </swiper>
   <view class="dots">
    <swiper autoplay="auto" interval="5000" display-multiple-items="7" duration="500" current="{{dotsCurrent}}" circular="{{circular}}" bindchange="dotsChange">
     <block wx:for="{{slider}}" wx:key="unique">
      <swiper-item data-id="{{item.id}}" class="dot{{index == swiperCurrent ? ' active' : ''}}" bindtap="chuangEvent" id="{{index}}">
       <image src="{{item.picUrl}}" class="imgs"></image>
      </swiper-item>
     </block>
    </swiper>
   </view>
 
  </view>
 </view>
</view>

wxss:

/* pages/shouye/shouye.wxss */
 
page {
 background: #333;
 width: 100%;
 height: 100%;
 overflow: hidden;
}
 
#content {
 background: #333;
 width: 100%;
 height: 100%;
 overflow: hidden;
}
 
a {
 width: 100%;
 height: 50px;
 overflow: hidden;
}
 
/*banner轮播 */
 
.swiper-container {
 margin-top: 23%;
 position: relative;
}
 
.swiper-container .swiper {
 height: 600rpx;
}
 
.swiper-container .swiper .img {
 width: 100%;
 height: 100%;
}
 
.swiper-container .dots {
 position: fixed;
 height: 80px;
 right: 0rpx;
 width: 100%;
 bottom: 0rpx;
}
 
.swiper-container .dots .dot {
 /* margin: auto 3px; */
 /* width: 58px !important; */
 height: 65px !important;
 /* background: #333; */
 /* transition: all 0.6s; */
}
 
.swiper-container .dots .dot.active .imgs {
 width: 100% !important;
 height: 100%;
 margin: 0% auto;
}
 
.imgs {
 width: 85%;
 display: block;
 margin: 5% auto;
 height: 90%;
}
 
.swiper-container .dotes {
 position: absolute;
 right: 40rpx;
 bottom: 20rpx;
 display: flex;
 justify-content: center;
}
 
.swiper-container .dotes .dote {
 margin: 0 10rpx;
 width: 28rpx;
 height: 28rpx;
 background: #fff;
 border-radius: 50%;
 transition: all 0.6s;
 font: 300 18rpx/28rpx "microsoft yahei";
 text-align: center;
}
 
.swiper-container .dotes .dote.actives {
 background: #f80;
 color: #fff;
}

js

//banner
Page({
 data: {
  //轮播图
  slider: [],
  swiperCurrent: 3,
  slider: [{
   url: '', picUrl: 'images/1.jpg'
  },
  {
   picUrl: 'images/5.jpg'
  },
  {
   picUrl: 'images/3.jpg'
  },
  {
   picUrl: 'images/4.jpg'
  },
  {
   picUrl: 'images/5.jpg'
  },
  {
   picUrl: 'images/3.jpg'
  },
  {
   picUrl: 'images/5.jpg'
  },
  {
   picUrl: 'images/3.jpg'
  },
  {
   picUrl: 'images/5.jpg'
  },
  {
   picUrl: 'images/3.jpg'
  },
  {
   picUrl: 'images/5.jpg'
  },
  {
   picUrl: 'images/3.jpg'
  }
  ],
  indicatorDots: true,
  autoplay: true,
  interval: 2000,
  duration: 1000,
  circular: true,
  beforeColor: "white",//指示点颜色 
  afterColor: "coral",//当前选中的指示点颜色 
 },
 //轮播图的切换事件 
 swiperChange: function (e) {
  //只要把切换后当前的index传给<swiper>组件的current属性即可 
  this.setData({
   swiperCurrent: e.detail.current
  })
 },
 dotsChange: function (e) {
  //只要把切换后当前的index传给<swiper>组件的current属性即可 
  this.setData({
   dotsCurrent: e.detail.current
  })
 },
 //点击指示点切换 
 chuangEvent: function (e) {
  this.setData({
   swiperCurrent: e.currentTarget.id
  })
 },
 chuangEvents: function (e) {
  this.setData({
   dotsCurrent: e.currentTarget.id
  })
 },
 
})

效果图:

微信小程序实现带缩略图轮播效果

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持三水点靠木。

Javascript 相关文章推荐
jQuery中将函数赋值给变量的调用方法
Mar 23 Javascript
js分页代码分享
Apr 28 Javascript
JS实现文档加载完成后执行代码
Jul 09 Javascript
JS延时提示框实现方法详解
Nov 26 Javascript
jQuery计算文本框字数及限制文本框字数的方法
Mar 01 Javascript
基于jquery实现百度新闻导航菜单滑动动画
Mar 15 Javascript
从零开始做一个pagination分页组件
Mar 15 Javascript
JS给按钮添加跳转功能类似a标签
May 30 Javascript
vue init webpack 建vue项目报错的解决方法
Sep 29 Javascript
JS html事件冒泡和事件捕获操作示例
May 01 Javascript
微信小程序 组件的外部样式externalClasses使用详解
Sep 06 Javascript
jquery插件实现轮播图效果
Oct 19 jQuery
微信小程序使用swiper组件实现层叠轮播图
Nov 04 #Javascript
微信小程序实现下拉菜单切换效果
Mar 30 #Javascript
微信小程序CSS3动画下拉菜单效果
Nov 04 #Javascript
vue-router判断页面未登录自动跳转到登录页的方法示例
Nov 04 #Javascript
浅谈React碰到v-if
Nov 04 #Javascript
微信小程序实现顶部下拉菜单栏
Nov 04 #Javascript
微信小程序使用template标签实现五星评分功能
Nov 03 #Javascript
You might like
Php注入点构造代码
2008/06/14 PHP
PHP扩展编写点滴 技巧收集
2010/03/09 PHP
php字符串截取的简单方法
2013/07/04 PHP
PHP数组去重比较快的实现方式
2016/01/19 PHP
Jquery操作下拉框(DropDownList)实现取值赋值
2013/08/13 Javascript
PhotoShop给图片自动添加边框及EXIF信息的JS脚本
2015/02/15 Javascript
JavaScript更改原始对象valueOf的方法
2015/03/19 Javascript
node.js操作mongodb学习小结
2015/04/25 Javascript
深入理解JavaScript 函数
2016/06/06 Javascript
Vue实现美团app的影院推荐选座功能【推荐】
2018/08/29 Javascript
如何使用puppet替换文件中的string
2018/12/06 Javascript
浅谈layui数据表格判断问题(加入表单元素),设置单元格样式
2019/10/26 Javascript
vue使用swiper.js重叠轮播组建样式
2019/11/14 Javascript
跟老齐学Python之编写类之三子类
2014/10/11 Python
Python Queue模块详细介绍及实例
2016/12/27 Python
virtualenv实现多个版本Python共存
2017/08/21 Python
详解Python异常处理中的Finally else的功能
2017/12/29 Python
pygame游戏之旅 python和pygame安装教程
2018/11/20 Python
python opencv 读取图片 返回图片某像素点的b,g,r值的实现方法
2019/07/03 Python
Tensorflow中tf.ConfigProto()的用法详解
2020/02/06 Python
python使用python-pptx删除ppt某页实例
2020/02/14 Python
python多进程 主进程和子进程间共享和不共享全局变量实例
2020/04/25 Python
详解python如何引用包package
2020/06/07 Python
canvas画图被放大且模糊的解决方法
2020/08/11 HTML / CSS
Nice Kicks网上商店:ShopNiceKicks.com
2018/12/25 全球购物
PatPat德国:妈妈的每日优惠
2019/10/02 全球购物
幼儿运动会邀请函
2014/01/17 职场文书
三爱活动实施方案
2014/03/19 职场文书
大学校务公开实施方案
2014/03/31 职场文书
科长竞聘演讲稿
2014/05/16 职场文书
2013年最新自荐信范文
2014/06/23 职场文书
大学生考试作弊检讨书
2014/09/21 职场文书
中学生学习保证书
2015/02/26 职场文书
企业法人代表证明书
2015/06/18 职场文书
MySQL时间设置注意事项的深入总结
2021/05/06 MySQL
面试中canvas绘制图片模糊图片问题处理
2022/03/13 Javascript