微信小程序点击切换图片

1,423 阅读1分钟

wxml 代码片段

<view class='aotopaly'>

<swiper current='{{curr}}' class='swiper' indicator-dots="{{true}}"

autoplay="{{false}}" interval="{{3000}}" duration="{{500}}">

<block wx:for="{{imgUrls}}">

<swiper-item>

<image src="{{item}}"/>

</swiper-item>

</block>

</swiper>

</view>

wxjs片段

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',

'http://img06.tooopen.com/images/20160818/tooopen_sy_175866434296.jpg',

'http://img06.tooopen.com/images/20160818/tooopen_sy_175833047715.jpg'

],

curr: 0,



},

/*点击切换页面*/

onclick:function(e){

var a = e.currentTarget.dataset.index

this.setData({

curr: a

})

},







})
---------------------
作者:Mr.冬冬
来源:CSDN
原文:blog.csdn.net/weixin_4230…
版权声明:本文为博主原创文章,转载请附上博文链接!