微信小程序—swiper(滑块视图容器)
来源:互联网 发布:简单软件的c语言程序 编辑:程序博客网 时间:2024/05/17 20:10
官方api:https://mp.weixin.qq.com/debug/wxadoc/dev/component/swiper.html
滑块视图容器,这里我们使用这个视图实现轮播图的效果,
效果图如下,
1.index.js中:
//index.js//获取应用实例const app = getApp()var dotsFirst = true;var isCircularFirst = true;var isVerticalFirst = true;Page({ data: { isCircular: true,//默认衔接滑动 interval: 3000,//默认自动切换时间间隔 duration: 1000,//默认滑动动画时长 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' ], }, onLoad: function () { }, //显示/隐藏指示器 showDots: function () { if (dotsFirst == true) { dotsFirst = false; this.setData({ indicatorDots: true, }); } else { dotsFirst = true; this.setData({ indicatorDots: false, }); } }, //设置,取消衔接滑动 showCircular: function () { if (isCircularFirst == true) { isCircularFirst = false; this.setData({ isCircular: true, }); } else { isCircularFirst = true; this.setData({ isCircular: false, }); } }, //设置,取消滑动方向是否为纵向 showVertical: function () { if (isVerticalFirst == true) { isVerticalFirst = false; this.setData({ vertical: true, }); } else { isVerticalFirst = true; this.setData({ vertical: false, }); } }, //设置指示器颜色事件 icInput: function (e) { this.setData({ indicatorColor: e.detail.value }) }, //设置自动切换时间的间隔事件 iInput: function (e) { this.setData({ interval: e.detail.value }) }, //设置自动切换时间的间隔事件 dInput: function (e) { this.setData({ duration: e.detail.value }) }, //设置当前选中的指示点颜色事件 iacInput: function (e) { this.setData({ indicatorActiveColor: e.detail.value }) },})
2.index.wxml中:
<swiper indicator-dots="{{indicatorDots}}" indicator-color="{{indicatorColor}}" autoplay='{isAutoplay}' current='0' interval="{{interval}}" duration="{{duration}}" circular="{{isCircular}}" vertical="{{vertical}}" indicator-active-color="{{indicatorActiveColor}}"> <block wx:for="{{imgUrls}}" wx:key="imageKey"> <swiper-item> <image src="{{item}}" class="image" /> </swiper-item> </block></swiper><button class='buton' catchtap='showDots'>显示/隐藏指示器</button><button class='buton' catchtap='showCircular'>设置/取消衔接滑动</button><button class='buton' catchtap='showVertical'>设置/取消滑动方向是否为纵向</button><view> <view class='text'>设置指示器的颜色(请使用十六进制颜色值,例如:#ff00ff)</view> <input class="input" placeholder="" value="#" bindinput="icInput" confirm-type="done" focus/></view><view> <view class='text'>设置自动切换时间间隔(单位毫秒(ms),例如:3000就是3秒)</view> <input class="input" placeholder="" type="number" value="3000" bindinput="iInput" confirm-type="done" focus/></view><view> <view class='text'>设置滑动动画时长(单位毫秒(ms),例如:1000就是1秒)</view> <input class="input" placeholder="" type="number" value="1000" bindinput="dInput" confirm-type="done" focus/></view><view> <view class='text'>设置当前选中的指示点颜色(请使用十六进制颜色值,例如:#ff00ff)</view> <input class="input" placeholder="" value="#" bindinput="iacInput" confirm-type="done" focus/></view>
3.index.wxss中:
.image { width: 100%;}.buton { margin-top: 10rpx;}.input { width: 100%; padding-left: 10rpx; margin-top: 10rpx; font-size: 35rpx; background-color: #ccc;}.text { font-size: 35rpx; margin-top: 10rpx; padding-left: 10rpx;}
4.demo下载地址:
http://download.csdn.net/download/afanbaby/10158552
本人菜鸟一个,有什么不对的地方,希望大家指出评论,大神勿喷,希望大家一起学习进步!
阅读全文
0 0
- 微信小程序—swiper(滑块视图容器)
- 微信小程序之滑块视图容器(swiper)
- 2.1.3微信小程序滑块视图容器 swiper
- swiper-滑块视图容器
- 微信小程序的视图容器—swiper
- 实现滑块视图容器 swiper
- 【微信小程序】视图容器-swiper组件
- 04、swiper 滑块视图容器的使用
- 小程序开发总结3:swiper滑块视图
- 微信小程序:视图容器
- 微信小程序-view(视图容器)
- 微信小程序入门实例——swiper
- 微信小程序 swiper 应用
- 3、微信小程序笔记---视图容器
- 【微信小程序】视图容器-view组件
- 【微信小程序】视图容器-scroll-view组件
- 微信小程序组件1--视图容器
- 微信小程序基础组件之视图容器
- c/c++面试题
- zookeeper 集群安装
- Apache Tiles 学习(二)、Java Web应用中使用Apache Tiles
- project euler 4
- 做项目时后端处理json数据
- 微信小程序—swiper(滑块视图容器)
- Python代码中的捕捉性能-CPU分析(Python脚本)
- 抽象类和接口
- SpringMVC中@Controller和@RequestMapping用法和其他常用注解
- 【算法】算法分析与设计的基本方法
- 去掉EditText的默认焦点
- 用IOT的思维来管理我们的查看我们重要业务的服务器健康状态-Azure配置篇!
- Android开发中线程和线程池的使用
- 2017 icpc Southeast USA J 题 Gym