微信小程序实现带放大效果的轮播图


Posted in Javascript onMay 26, 2020

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

效果如图

微信小程序实现带放大效果的轮播图

WXML

<!-- 轮播图 -->
 <view class='Carousel'>
 <view class="recommend">
  <view class="swiper-container">
  <swiper class="swiper" autoplay="auto" interval="2000" duration="500" bindchange="swiperChange" previous-margin="40px" next-margin="40px" circular="true">
   <block wx:for="{{slider}}" wx:key="unique">
   <swiper-item data-url="{{item.linkUrl}}">
    <image class='{{swiperCurrent==item.imgId?"img_current":"img"}}' src="{{item.picUrl}}" mode="widthFix"></image>
   </swiper-item>
   </block>
  </swiper>
  <!-- 指示点 -->
  <!-- <view class="dots">
   <block wx:for="{{slider}}" wx:key="unique">
   <view class="dot{{index == swiperCurrent ? ' active' : ''}}" bindtap="chuangEvent" id="{{index}}">{{index+1}}</view>
   </block>
  </view> -->
  </view>
 </view>
</view>

WXSS

.Carousel{
 margin-top: 49px;
 background-color: #fff;
}
.swiper-container{
 position: relative;
}
.swiper-container .swiper{
 padding-top: 8px;
 height: 380rpx;
 text-align: center;
}
swiper-item{
 display: flex;
 align-items: center;
 justify-content: space-around;
}
.swiper-container .swiper .img{
 width: 88%;
 height: 88%;
 border-radius: 10px;
}
.img_current{
 width: 100%;
 height: 100%;
 border-radius: 10px;
}
.swiper-container .dots{
 position: absolute;
 right: 40rpx;
 bottom: 20rpx;
 display: flex;
 justify-content: center;
}
.swiper-container .dots .dot{
 width: 28rpx;
 height: 28rpx;
 margin: 0 10rpx;
 border-radius: 50%;
 background: #fff;
 transition: all .6s;
 font: 300 18rpx/28rpx "microsoft yahei";
 text-align: center;
}
.swiper-container .dots .dot.active{
 background: #f80;
 color:#fff;
}

JS

data: { 
 //轮播图
 slider: [
  { imgId: '0', linkUrl: 1, picUrl: '/images/swiper/swiper_1.png' },
  { imgId: '1', linkUrl: 2, picUrl: '/images/swiper/swiper_2.png' }, 
  { imgId: '2', linkUrl: 3, picUrl: '/images/swiper/swiper_3.png' },
  ],
 swiperCurrent: 0,
 }
 
  /**
 * 轮播图
 */
 swiperChange: function (e) {
 //把切换后当前的index传给<swiper>组件的current属性
 this.setData({
  swiperCurrent: e.detail.current
 })
 },

 //点击指示点切换
 // chuangEvent: function (e) {
 // this.setData({
 //  swiperCurrent: e.currentTarget.id
 // })
 // },

为大家推荐现在关注度比较高的微信小程序教程一篇:《微信小程序开发教程》小编为大家精心整理的,希望喜欢。

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

Javascript 相关文章推荐
JS中使用Array函数shift和pop创建可忽略参数的例子
May 28 Javascript
2014年50个程序员最适用的免费JQuery插件
Dec 15 Javascript
JavaScript的Date()方法使用详解
Jun 09 Javascript
简单的JS轮播图代码
Jul 18 Javascript
网站申请不到支付宝接口、微信接口,免接口收款实现方式几种解决办法
Dec 14 Javascript
Angular2-primeNG文件上传模块FileUpload使用详解
Jan 14 Javascript
input框中自动展示当前日期yyyy/mm/dd的实现方法
Jul 06 Javascript
为vue-router懒加载时下载js的过程中添加loading提示避免无响应问题
Apr 03 Javascript
bootstrap select2插件用ajax来获取和显示数据的实例
Aug 09 Javascript
微信小程序当前时间时段选择器插件使用方法详解
Dec 28 Javascript
JavaScript使用表单元素验证表单的示例代码
Aug 20 Javascript
基于vue-cli3+typescript的tsx开发模板搭建过程分享
Feb 28 Javascript
vue实现图片上传功能
May 28 #Javascript
小程序实现图片移动缩放效果
May 26 #Javascript
jQuery实现的分页插件完整示例
May 26 #jQuery
js实现时间日期校验
May 26 #Javascript
Node.js API详解之 assert模块用法实例分析
May 26 #Javascript
Angular5整合富文本编辑器TinyMCE的方法(汉化+上传)
May 26 #Javascript
js校验开始时间和结束时间
May 26 #Javascript
You might like
如何删除多级目录
2006/10/09 PHP
获得Google PR值的PHP代码
2007/01/28 PHP
PHP与SQL注入攻击[三]
2007/04/17 PHP
php 远程关机操作的代码
2008/12/05 PHP
php4与php5的区别小结(配置异同)
2011/12/20 PHP
简单谈谈php中ob_flush和flush的区别
2014/11/27 PHP
php使用Jpgraph创建折线图效果示例
2017/02/15 PHP
基于jQuery的表格操作插件
2010/04/22 Javascript
Jquery下attr和removeAttr的使用方法
2010/12/28 Javascript
JS解析json数据并将json字符串转化为数组的实现方法
2012/12/25 Javascript
jquery.validate使用时遇到的问题
2015/05/25 Javascript
Bootstrap carousel轮转图的使用实例详解
2016/05/17 Javascript
一个炫酷的Bootstrap导航菜单
2016/12/28 Javascript
jQuery操作之效果详解
2017/05/19 jQuery
一份超级详细的Vue-cli3.0使用教程【推荐】
2018/11/15 Javascript
vue中的inject学习教程
2019/04/24 Javascript
Vue项目打包部署到iis服务器的配置方法
2019/10/14 Javascript
Vuex的各个模块封装的实现
2020/06/05 Javascript
[44:26]DOTA2上海特级锦标赛主赛事日 - 2 胜者组第一轮#4EG VS Fnatic第二局
2016/03/03 DOTA
[03:01]完美盛典趣味短片 DOTA2年度最佳&拉胯英雄
2019/12/07 DOTA
python操作MySQL数据库具体方法
2013/10/28 Python
最基础的Python的socket编程入门教程
2015/04/23 Python
python使用Tkinter显示网络图片的方法
2015/04/24 Python
Python中Collections模块的Counter容器类使用教程
2016/05/31 Python
使用Python读取安卓手机的屏幕分辨率方法
2018/03/31 Python
基于HTML5实现类似微信手机摇一摇功能(计算摇动次数)
2017/07/24 HTML / CSS
中国最大的名表商城:万表网
2016/08/29 全球购物
业务部经理岗位职责
2014/01/04 职场文书
岗位竞聘演讲稿
2014/01/10 职场文书
二年级小学生评语
2014/04/21 职场文书
竞聘演讲稿精彩开头和结尾
2014/05/14 职场文书
工厂仓管员岗位职责范本
2014/07/17 职场文书
四风问题党员个人整改措施
2014/10/27 职场文书
2015年乡镇残联工作总结
2015/05/13 职场文书
python3.7.2 tkinter entry框限定输入数字的操作
2021/05/22 Python
Python OpenGL基本配置方式
2022/05/20 Python