微信小程序 开发之滑块视图容器(swiper)详解及实例代码
2019/6/27 21:08:49
本文主要是介绍微信小程序 开发之滑块视图容器(swiper)详解及实例代码,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
微信小程序 开发之滑块视图容器详解
实现效果图:
实现起来特别简单,看看代码是怎么写的呢:
<swiper class="swiper" indicator-dots="{{indcatorDots}}" autoplay="{{autoPlay}}" interval="{{interval}}" duration="{{duration}}"> <block wx:for="{{imgUrls}}" wx:for-index="index"> <swiper-item> <image src="{{item}}" class="side-img"></image> </swiper-item> </block> </swiper>
这就是布局了,看一下js里面代码:
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'], indcatorDots: true, autoPlay: true, interval: 5000, duration: 500 },
,swiper有以下一些常用属性:
标记的两个属性暂时不管。
注意:其中只可放置组件,否则会导致未定义的行为。
swiper-item
仅可放置在组件中,宽高自动设置为100%。
就是这样,自己动手试试。
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
这篇关于微信小程序 开发之滑块视图容器(swiper)详解及实例代码的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-10-04package.json 文件位置在哪?-icode9专业技术文章分享
- 2024-10-01Craco.js学习:从入门到实践指南
- 2024-10-01Create-React-App学习:入门与实践指南
- 2024-10-01CSS-in-JS学习:从入门到实践指南
- 2024-09-30JSX语法学习:从入门到初步掌握
- 2024-09-30Mock.js学习:入门教程与实战演练
- 2024-09-30React Hooks学习:从入门到实践
- 2024-09-30受控组件学习:React中的基础入门教程
- 2024-09-29JS定时器教程:初学者必看指南
- 2024-09-29JS对象教程:初学者的全面指南