微信小程序 swiper 显示图片计数 当前/总数
2024-10-13 04:11:46
<view class="swiperContainer">
<swiper bindchange="swiperChange" autoplay="{{autoplay}}" duration="{{duration}}" style='height: 380rpx;'>
<block wx:for="{{imgUrls}}" wx:key="*this">
<swiper-item wx:key="*this">
<image src="{{item}}" class="slide-image" class='img' />
</swiper-item>
</block>
</swiper>
<view class="imageCount">{{current+}}/{{imgUrls.length}}</view>
</view>
.swiperContainer {
position: relative;
}
.img {
width: %;
height:100%;
}
.imageCount {
width:120rpx;
height:50rpx;
background-color: rgba(, , , 0.3);
border-radius:40rpx;
line-height:50rpx;
color:#fff;
text-align:center;
font-size:26rpx;
position:absolute;
left:13px;
bottom:20rpx;
}
Page({
data: {
duration:"",
imgUrls: [
'https://cdn.cnbj0.fds.api.mi-img.com/b2c-mimall-media/b51889744910df7979a2f672434da84e.jpg?thumb=1&w=720&h=360',
'https://cdn.cnbj0.fds.api.mi-img.com/b2c-mimall-media/37dfdc929ee9a4313facb0b23ebcd721.jpg?thumb=1&w=720&h=360',
'https://cdn.cnbj0.fds.api.mi-img.com/b2c-mimall-media/a0ff3dc30027f3b615bfe03f1d306ee5.jpg?thumb=1&w=720&h=360',
'https://cdn.cnbj0.fds.api.mi-img.com/b2c-mimall-media/2320573b3be643e29f5270a97e1a9c1d.jpg?thumb=1&w=720&h=360'
],
current:
},
swiperChange: function (e) {
var that = this;
if (e.detail.source == 'touch') {
that.setData({
current: e.detail.current
})
}
},
onLoad: function (options) {
var that = this;
},
onReady: function () { },
onShow: function () { }, /**
* 用户点击右上角分享
*/
onShareAppMessage: function () { }
})
最新文章
- Android获取位置信息的方法总结
- Linux安装JDK1.8
- SDRAM操作原理分析
- 前端模块化:RequireJS
- jnlp jws
- Vue.js常见问题
- selenium--下拉列表选择
- ASCII 码表对照 2
- (转)poj1182食物链
- Java数据库连接错误集
- firebug离线安装方法-拖入法
- spring mvc报错,数据库查询无限死循环
- 介绍Dynamics 365的OrgDBOrgSettings工具
- oracle nvl2函数
- Centos7上安装mariadb
- SpringBoot单元测试示例2
- SQL Server在本地计算机上用SSMS(SQL Server Management Studio)登录不上,错误消息:(Microsoft SQL Server, Error: 18456)
- [Functional Programming] Using JS, FP approach with Arrow or State Monad
- R语言学习笔记—决策树分类
- [NOIP2017]时间复杂度(模拟)
热门文章
- Vim 插键及配置
- php中的正则函数:正则匹配,正则替换,正则分割 所有的操作都不会影响原来的字符串.
- try finally 执行顺序问题
- 【模板】关于c++的代码模板
- ElasticSearch——日志工具
- Vim-编辑器之神
- ES6中Promise的入门(结合例子)
- springboot 启动报错 java.lang.IllegalStateException: Failed to introspect annotated methods on class org
- sublime3 mac : Package Control There are no packages available for installation
- Java Object类及其equals方法