微信小程序8-swiper(滑动面板)
来源:互联网 发布:上海优越感知乎 编辑:程序博客网 时间:2024/06/08 12:54
swiper就是为了以后做轮播图用的。下面是一些它的属性
.
1.首先新建一个page(记得在app.json中注册),上效果图。
.
2.index.wxml中的代码
<swiper class="view-item" indicator-dots="true" autoplay="true"><swiper-item class="bg-green"><view >Content</view></swiper-item><swiper-item class="bg-yellow"><view >Content</view></swiper-item><swiper-item class="bg-blue"><view >Content</view></swiper-item></swiper>
注意:在swiper标签中只可放置swiper-item组件,其他标签如果不放在swiper-item的标签下是没用的,会被自动屏蔽
注意:要想实现滑动面板,必须有swiper和swiper-item这两个标签,一个是控制整个轮播的大小和样式。而swiper-item控制子视图。
indicator-dots=”true”—就是那三个小点,显示是true隐藏是false
autoplay=”true”—是否自动播放。
current=“2”—首先显示的是第(i-1)个视图,i-1是因为它和数组一样,是从0开头的。
interval=”1000”—是指隔几秒换一个图片,1000是1秒
duration=”3000”—是指从一个页面滑动另一个页面所需要的时间,但我发现一个有趣的现象,如果你interval=”1000”的话,它一个页面还没滑动完就,想滑动到第三个页面。
3.官方提供的代码 有意思的是它居然没效果,刚开始我还以为自己哪里错了,最后才发现官方吧swiper写成swpier,开来微信小程序还待完善啊。先上效果图
index.wxml中
<swpier indicator-dots="{{indicatorDots}}" autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}"> <block wx:for-items="{{imgUrls}}"> <swpier-item> <image src="{{item}}" class="slide-image" width="355" height="150"/> </swpier-item> </block></swpier><button bindtap="changeIndicatorDots"> indicator-dots </button><button bindtap="changeAutoplay"> autoplay </button><slider bindchange="intervalChange" show-value min="500" max="2000"/> interval<slider bindchange="durationChange" show-value min="1000" max="10000"/> duration
index.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' ], indicatorDots: false, autoplay: false, interval: 5000, duration: 1000 }, changeIndicatorDots: function(e) { this.setData({ indicatorDots: !this.data.indicatorDots }) }, changeAutoplay: function(e) { this.setData({ autoplay: !this.data.autoplay }) }, intervalChange: function(e) { this.setData({ interval: e.detail.value }) }, durationChange: function(e) { this.setData({ duration: e.detail.value }) }})
其实,你应该也发现了,微信小程序的index.wxml和index.wxss文件很好理解并且很好上手,难点就在于index.js和index.json的理解,也就是对程序逻辑的处理。
0 0
- 微信小程序8-swiper(滑动面板)
- 微信小程序swiper滑动页面
- 微信小程序 swiper 点击切换,左右滑动,自动滑动
- 微信小程序swiper滑动页面实践-类似于安卓ViewPager
- 微信小程序swiper滑动页面实践-类似于安卓ViewPager
- 微信小程序把玩(十)swiper组件
- 微信小程序(轮播图 swiper组件)
- 学习微信小程序--组件(swiper)
- 微信小程序组件(二)swiper
- 微信小程序 swiper 应用
- 微信小程序之swiper轮播图
- 微信小程序入门之swiper
- 微信小程序中的swiper组件
- 微信小程序----组件之swiper
- 微信小程序 自定义 swiper 样式
- 微信小程序swiper使用注意
- 微信小程序之swiper轮播图
- 微信小程序----折叠面板(MUI折叠面板)
- 动规第一天
- 练习题2016.11.7
- 联合体(union)的使用方法及其本质
- 深度学习框架Caffe学习笔记(1)-Caffe环境搭建
- JVM(2)对象分配、布局、访问
- 微信小程序8-swiper(滑动面板)
- 递归、栈、非递归非栈实现二叉树的遍历
- 最短路几种算法对比
- HDU ACM 11 2079 选课时间 母函数或者DP
- 2016年11月7日学习总结
- Java 23种设计模式总结,收录学习
- leetcode_258
- 一个DirectDraw入门程序
- 基于Maven实现war包继承