3_圖片輪播
圖片輪播使用
1. 業務代碼
var app = getApp()
Page({
data: {
movies: [
{ id: 1, img: "http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg" },
{ id: 2, img: "http://img06.tooopen.com/images/20160818/tooopen_sy_175866434296.jpg" },
{ id: 3, img: "http://img06.tooopen.com/images/20160818/tooopen_sy_175833047715.jpg" },
]
},
onLoad: function () {},
-
// 每一個item的點擊事件
onItemClick: function (event) {
wx.showToast({
title: event.target.dataset.postid + "",
})
}
})
2. 界面UI
<swiper class="swiper" indicator-dots="true" autoplay="true" interval="5000" duration="1000" circular='true' bindtap="onItemClick">
-
<block wx:for="{{movies}}" wx:for-index="index">
<swiper-item>
-
<image src="{{item.img}}" class="slide-image" mode="aspectFill" data-postId="{{item.id}}"/>
-
</swiper-item>
-
</block>
-
-
</swiper>
歡迎關注本站公眾號,獲取更多信息