学习笔记_微信小程序开发--组建Swiper的使用
2017-04-21 18:12
916 查看
Swiper的使用
.js文件
var imgUrls = [= { image: "http://www.padmag.cn/wp-content/uploads/Unforgiven.jpg" }, { image: "http://www.padmag.cn/wp-content/uploads/Desire.jpg" }, { image: "http://www.padmag.cn/wp-content/uploads/No_Goodbye.jpg" }, { image: "http://www.padmag.cn/wp-content/uploads/Look_Away.jpg" } ] Page({ data: { imgUrls: imgUrls, autoplay: true,//是否自动切换 indicatorDots: true,//是否显示圆点 interval: 5000,//自动切换间隔 duration: 500, //滑动动画时长 indicatorColor: "blue",//滑动圆点颜色 indicatorActiveColor: "white", //当前圆点颜色 current: 2, //当前所在页面的 index circular: true //是否采用衔接滑动 //其中只可放置<swiper-item/>组件,否则会导致未定义的行为。 }, imageLoad: function () { //bindload 图片加载的时候自动设定宽度 this.setData({ imageWidth: wx.getSystemInfoSync().windowWidth }) }, swiperChange: function () { console.log("current 改变时会触发 change 事件") } })
.wxml文件
<swiper indicator-dots="{{indicatorDots}}" current="{{current}}" circular="{{circular}}" indicator-active-color="{{indicatorActiveColor}}" indicator-color="{{indicatorColor}}" autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}" bindchange="swiperChange"> <block wx:for="{{imgUrls}}" wx:key="image"> <swiper-item> <image src="{{item.image}}" model="aspectFit" style="width: {{imageWidth}}px;" bindload="imageLoad" /> </swiper-item> </block> </swiper>
相关文章推荐
- 微信小程序开发学习笔记003--微信小程序页面布局
- 第10课:底实战详解使用Java开发Spark程序学习笔记
- Java学习笔记--使用Javadoc生成程序开发文档
- 【微信小程序开发】学习笔记第1天-
- 微信小程序开发学习笔记004--微信小程序语法结构
- 微信小程序开发学习笔记006--微信小程序组件详解02
- 学习笔记_微信小程序开发--常用快捷键
- 【hadoop】Hadoop学习笔记(九):如何在windows上使用eclipse远程连接hadoop进行程序开发
- 微信小程序开发 -- 学习笔记
- Python学习笔记(二)——使用Eclipse开发Python程序
- 微信小程序开发学习笔记005--微信小程序组件详解
- 微信小程序开发学习笔记007--微信小程序项目01
- 微信小程序开发学习笔记008--微信小程序项目02
- 微信小程序开发学习笔记001--认识微信小程序,第一个微信小程序
- 微信小程序开发学习笔记002--微信小程序框架解密
- 微信小程序学习笔记1——开发环境搭建
- 第10课:底实战详解使用Java开发Spark程序学习笔记(二)
- Hadoop学习笔记(九):如何在windows上使用eclipse远程连接hadoop进行程序开发
- WPF下的地图开发控件(GMap.NET)使用心得—— GMap学习笔记(二)
- OK6410 Linux开发环境搭建--编译以及ubuntu的使用方法学习笔记