小程序 轮播图标点样式设置(可设置大小 颜色 形状)
轮播图xml
<view class='swiper'> <swiper class="swiper-box" indicator-dots="{{true}}" autoplay="{{false}}" bindchange="bindchange" style="height:{{imgheight}}rpx;" indicator-color="{{indicatorCo}}" indicator-active-color="{{indicatoraAC}}"> <block wx:for='{{imgUrls}}' wx:key="{{index}}"> <swiper-item> <image src="{{item}}" data-id='{{index}}' bindtap="SwiperImageClick" class="slide-image" mode="widthFix" bindload="imageLoad" style="height:{{imgheight}}rpx;" /> </swiper-item> </block> </swiper> </view>
计算图片大小的js
imageLoad: function (e) {//获取图片真实宽度 var imgwidth = e.detail.width, imgheight = e.detail.height, //宽高比 ratio = imgwidth / imgheight; console.log(imgwidth, imgheight) //计算的高度值 var viewHeight = 750 / ratio; var imgheight = viewHeight; var imgheights = this.data.imgheights; //把每一张图片的对应的高度记录到数组里 // imgheights[e.target.dataset.id] = imgheight; this.setData({ imgheight: imgheight }) },
标点样式css
/* 一下四个样式是轮播图标点设置样式 */ .swiper-box .wx-swiper-dots.wx-swiper-dots-horizontal { margin-bottom: 2rpx; } .swiper-box .wx-swiper-dot { width: 12rpx; display: inline-flex; height: 12rpx; /* margin-left: 20rpx; */ justify-content: space-between; } .swiper-box .wx-swiper-dot::before { content: ''; flex-grow: 1; background: rgba(255, 255, 255, 0.8); border-radius: 8rpx; } .swiper-box .wx-swiper-dot-active::before { background: rgba(244, 0, 0, 0.8); }
相关推荐
微信小程序 swiper 组件实现层叠轮播图,同时自定义指示点样式和图片描述信息
微信小程序swiper,滑块视图容器,使用这个视图实现轮播图的效果。
淘宝swiper轮播 小图变大图 没有让未激活的图片旋转
swiper - 小程序 自定义轮播 类旋转木马
主要介绍了微信小程序swiper实现滑动放大缩小效果,本文通过实例代码给大家介绍的非常详细,具有一定的参考借鉴价值,需要的朋友可以参考下
swiper轮播图分页器样式修改
主要为大家详细介绍了微信小程序实现3D轮播图效果,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
小程序3D轮播,旋转木马轮播组件
移动端 swiper轮播做下拉加载上拉回到顶部,上下左右轮播功能demo, 请在浏览器手机模式下打开,打开后,再刷新一次。
前端开发swiper焦点图实例,类似于https://www.swiper.com.cn/demo/web/index.html所示效果。
使用Swiper 插件实现 类似于轮播图的视频轮播 轮播图
基于mpvue的小程序swiper类3d轮播
2018年03月20日,项目中要实现一个比较有意思的轮播效果(这个页面要实现好几个轮播),[线上地址](http://http://www.risfond.com/bdm),Swiper一直用的很顺手,于是继续用Swiper,效果图如下。实际效果一点都不...
swiper实现轮播图几乎是没有一点点技术含量,但是用起来却很方便,包括对移动端的支持也很好。 由于简单这里当然就不会去详细介绍了,下面就来开始本文的正文内容 实现过程: 一.移动端-需求swiper 4.0.3实现层叠轮播 ...
微信小程序 swiper 轮播图 前言: 1.更新了v0.12的版本后,每次保存都弹出来一个打开文件窗口。 2.swiper组件的属性indicator-dots,值为false时,面板指示点还是显示。要把indicator-dots属性直接删掉。 下面进入...
轮播——小圆点
一个小程序swiper 3D 切换的代码,可以供你参考从而实现你需要的样式,内容自适应
通过微信小程序的滑块视图容器swiper及swiper-item实现tab切换功能,同时实现下拉刷新,上拉加载更多功能。
swiper实现当前轮播图放大效果,类似芒果tv,货拉拉实现效果,自己整理修改了很多次,希望能给有效地帮助
主要介绍了微信小程序之swiper轮播图中的图片自适应高度的方法,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧