微信小程序修改swiper默认指示器样式的实例代码
2019/6/27 7:50:12
本文主要是介绍微信小程序修改swiper默认指示器样式的实例代码,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
修改官方swiper样式
从微信官方微信开发文档中心复制swiper 代码块。
wxml定义
<view class="wrap"> <swiper class="swipers" autoplay="{{autoplay}}" current="{{currentSwiper}}" bindchange="swiperChange"> <block wx:for="{{imgUrls}}"> <swiper-item> <image src="{{item}}" class="slide-image" width="100%" height="150" ></image> </swiper-item> </block> </swiper> <!--重置小圆点的样式 --> <view class="dots"> <block wx:for="{{imgUrls}}"> <view class="dot{{index == currentSwiper ? ' active' : ''}}"></view> </block> </view> </view>
wxss定义样式
.wrap { height: auto; position: relative; width: 100%; } .swipers { height: 350rpx; width: 100%; } .slide-image { display: block; width: 100%; height: 100%; } /*用来包裹所有的小圆点 */ .dots { width: 156rpx; height: 36rpx; display: flex; flex-direction: row; position: absolute; left: 320rpx; bottom: 20rpx; } /*未选中时的小圆点样式 */ .dot { width: 26rpx; height: 26rpx; border-radius: 50%; margin-right: 26rpx; background-color: white; } /*选中以后的小圆点样式 */ .active { width: 26rpx; height: 26rpx; background-color: coral; }
赋值
Page({ data: { imgUrls: [ 'http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg', 'http://img06.tooopen.com/images/20160818/tooopen_sy_175866434296.jpg', 'http://img06.tooopen.com/images/20160818/tooopen_sy_175833047715.jpg' ], currentSwiper: 0, autoplay: true }, swiperChange: function (e) { this.setData({ currentSwiper: e.detail.current }) } })
效果图:
总结
以上所述是小编给大家介绍的微信小程序修改swiper默认指示器样式的实例代码,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对找一找教程网网站的支持!
这篇关于微信小程序修改swiper默认指示器样式的实例代码的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-05-30React Native常用组件-点击组件
- 2024-05-30uniapp+vue3+uv-ui手机端后台OA管理模板
- 2024-05-29Python网络爬虫的时候json=就是让你少写个json.dumps()
- 2024-05-27React Native常用组件-展示组件
- 2024-05-27React Native常用组件-列表组件
- 2024-05-09vue3开发前端表单缓存自定义指令,移动端h5必备插件
- 2024-05-09React Hooks在class组件中的使用方式
- 2024-03-30[OIDC in Action] 2. 基于OIDC(OpenID Connect)的SSO(纯JS客户端)
- 2024-03-29terraform jsonencode
- 2024-03-13vuex-persist