微信小程序swiper实现轮播图,可触发点击事件
2016-12-30 15:26
1116 查看
实现微信小程序轮换图切换,点击获取图片url,获取当前位置
1、index.js
Page({
data: {
autoplay: true,
dotsBoll: false,
interval: 2000,
duration: 1000,
current:0,
imageUrls: [
'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'
]
},
intervalChange: function (e) {//自动切换时间间隔
this.setData({
interval: e.detail.value
})
},
durationChange: function (e) {//滑动动画时长
duration: e.detail.value
},
changeIndicatorDots: function (e) {//是否显示小圆圈
this.setData({
dotsBoll: !this.data.dotsBoll
})
},
changeAutoplay: function (e) {//是否自动播放
this.setData({
autoplay: !this.data.autoplay
})
},
swipclick: function (e) {//点击图片触发事件
console.log(this.data.imageUrls[this.data.current]);
},
bindchange:function(e){//轮播图发生改变
this.setData({
current:e.detail.current
})
}
})
2、index.wxml
<swiper indicator-dots="{{dotsBoll}}" interval="{{interval}}" duration="{{duration}}" autoplay="{{autoplay}}" bindchange="bindchange">
<block wx:for-items="{{imageUrls}}">
<swiper-item >
<image src="{{item}}" height="150" width="355" bindtap="swipclick"></image>
</swiper-item>
</block>
</swiper>
<button bindtap="changeIndicatorDots"> indicator-dots </button>
<button bindtap="changeAutoplay"> autoplay </button>
<slider bindchange="intervalChange" show-value min="500" max="2000"/>
<slider bindchange="durationChange" show-value min="1000" max="10000"/>
1、index.js
Page({
data: {
autoplay: true,
dotsBoll: false,
interval: 2000,
duration: 1000,
current:0,
imageUrls: [
'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'
]
},
intervalChange: function (e) {//自动切换时间间隔
this.setData({
interval: e.detail.value
})
},
durationChange: function (e) {//滑动动画时长
duration: e.detail.value
},
changeIndicatorDots: function (e) {//是否显示小圆圈
this.setData({
dotsBoll: !this.data.dotsBoll
})
},
changeAutoplay: function (e) {//是否自动播放
this.setData({
autoplay: !this.data.autoplay
})
},
swipclick: function (e) {//点击图片触发事件
console.log(this.data.imageUrls[this.data.current]);
},
bindchange:function(e){//轮播图发生改变
this.setData({
current:e.detail.current
})
}
})
2、index.wxml
<swiper indicator-dots="{{dotsBoll}}" interval="{{interval}}" duration="{{duration}}" autoplay="{{autoplay}}" bindchange="bindchange">
<block wx:for-items="{{imageUrls}}">
<swiper-item >
<image src="{{item}}" height="150" width="355" bindtap="swipclick"></image>
</swiper-item>
</block>
</swiper>
<button bindtap="changeIndicatorDots"> indicator-dots </button>
<button bindtap="changeAutoplay"> autoplay </button>
<slider bindchange="intervalChange" show-value min="500" max="2000"/>
<slider bindchange="durationChange" show-value min="1000" max="10000"/>
相关文章推荐
- 微信小程序中点击View中任何位置都可以触发相应事件的解决办法
- 微信小程序使用swiper组件实现类3D轮播图
- 微信小程序例子——实现button点击事件改变数据值
- 微信小程序开发一swiper轮播图的简单实现
- Android开发(11)-利用listview控件显示person表中的所有数据(并实现点击触发拨号程序)
- UITextField 点击事件 --- 不触发键盘弹出,而触发其他事件的实现
- jquery实现点击某元素之外触发事件
- 微信小程序例子——点击文字实现页面跳转
- Android onKeyUp事件 实现连续点击两次退出程序
- js 基础篇必看(点击事件轮播图的简单实现)
- JQuery实现点击div里面的a的能触发点击时间,但是不触发外面的div的点击事件
- 微信小程序例子——使用swiper组件实现图片切换
- 回车直接实现点击某按钮的效果即触发单击事件
- Android程序:多按钮点击事件的常用功能实现
- 一周乱弹(1,摸态框增加纵向滚动条2,jQuery 鼠标点击事件3,通过ajax实现批量导出。4,windows查询占用某个端口号程序并杀死其进程)
- jquery实现点击label的同时触发文本框点击事件的方法
- 微信小程序 轮播图 swiper图片组件
- 实现一个EditText中间有字,字两边都可点击触发事件的效果
- 微信小程序的轮播图swiper问题