知識
不管是網(wǎng)站,軟件還是小程序,都要直接或間接能為您產(chǎn)生價值,我們在追求其視覺表現(xiàn)的同時,更側(cè)重于功能的便捷,營銷的便利,運營的高效,讓網(wǎng)站成為營銷工具,讓軟件能切實提升企業(yè)內(nèi)部管理水平和效率。優(yōu)秀的程序為后期升級提供便捷的支持!
您當(dāng)前位置>首頁 » 新聞資訊 » 小程序相關(guān) >
五分鐘掌握微信小程序輪播圖
發(fā)表時間:2021-3-31
發(fā)布人:葵宇科技
瀏覽次數(shù):49
微信小程序輪播圖實現(xiàn),比Android 輪播圖來說,顯得輕松多了。微信小程序提供swiper組件,官網(wǎng)api提供的swiper滑塊視圖容器。
從公共庫v1.4.0開始,change事件返回detail中包含一個source字段,表示導(dǎo)致變更的原因,可能值如下:
autoplay 自動播放導(dǎo)致swiper變化;
touch 用戶劃動引起swiper變化;
其他原因?qū)⒂每兆址硎尽?/p>
注意:其中只可放置
swiper-item
僅可放置在
index.wxss
swiper {
height: 421.5rpx;
}
swiper-item image {
width: 100%;
height: 100%;
}
.swiper-container{
position: relative;
}
.swiper-container .swiper{
height: 300rpx;
}
.swiper-container .swiper .img{
width: 100%;
height: 100%;
}
index.js
Page({
data: {
swiperCurrent: 0,
indicatorDots: true,
autoplay: true,
interval: 3000,
duration: 800,
circular:true,
imgUrls: [
'https://p3.pstatp.com/large/43700001e49d85d3ab52',
'https://p3.pstatp.com/large/39f600038907bf3b9c96',
'https://p3.pstatp.com/large/31fa0003ed7228adf421'
],
links:[
'../user/user',
'../user/user',
'../user/user'
]
},
//輪播圖的切換事件
swiperChange: function (e) {
this.setData({
swiperCurrent: e.detail.current
})
},
//點擊指示點切換
chuangEvent: function (e) {
this.setData({
swiperCurrent: e.currentTarget.id
})
},
//點擊圖片觸發(fā)事件
swipclick: function (e) {
console.log(this.data.swiperCurrent);
wx.switchTab({
url: this.data.links[this.data.swiperCurrent]
})
}
})
index.wxml
class="swiper-container">
<swiper indicator-dots="{{indicatorDots}}" autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}" circular="{{duration}}" current="{{swiperCurrent}}" bindchange="swiperChange" class="swiper">
<block wx:for="{{imgUrls}}" wx:key="unique">
<swiper-item>
<image src="{{item}}" class="img" bindtap="swipclick" />
swiper-item>
block>
swiper>
view>
重要一點是圖片的點擊事件,官網(wǎng)沒明確指出。bindtap="swipclick"
swipclick: function (e) {
console.log(this.data.swiperCurrent);
wx.switchTab({
url: this.data.links[this.data.swiperCurrent]
})
}
效果圖
相關(guān)案例查看更多
相關(guān)閱讀
- 北京小程序開發(fā)
- 微信小程序開發(fā)入門課程
- 表單
- 網(wǎng)站沒排名
- 汽車拆解管理軟件
- 報廢車拆解管理系統(tǒng)
- 云南網(wǎng)站建設(shè)公司地址
- 軟件定制
- 百度小程序開發(fā)公司
- 云南網(wǎng)站建設(shè)首選
- 商標(biāo)注冊
- 昆明軟件定制
- 區(qū)塊鏈
- 網(wǎng)站建設(shè)方法
- 云南小程序開發(fā)首選品牌
- 云南花農(nóng)小程序
- 報廢車回收管理軟件
- 小程序
- 小程序的開發(fā)公司
- 模版信息
- 汽車回收系統(tǒng)
- 百度人工排名
- 云南手機網(wǎng)站建設(shè)
- 大理小程序開發(fā)
- web學(xué)習(xí)路線
- 買小程序被騙
- 云南軟件公司
- 汽車報廢管理
- 網(wǎng)站建設(shè)特性
- 小程序退款