国产成人精品18p,天天干成人网,无码专区狠狠躁天天躁,美女脱精光隐私扒开免费观看

微信小程序模板之分頁(yè)滑動(dòng)欄的示例分析

發(fā)布時(shí)間:2021-07-06 14:08 來(lái)源:億速云 閱讀:0 作者:小新 欄目: web開(kāi)發(fā)

這篇文章給大家分享的是有關(guān)微信小程序模板之分頁(yè)滑動(dòng)欄的示例分析的內容。小編覺(jué)得挺實(shí)用的,因此分享給大家做個(gè)參考,一起跟隨小編過(guò)來(lái)看看吧。

具體內容如下

功能:

1.分頁(yè)欄與滑動(dòng)視圖綁定
2.點(diǎn)擊分頁(yè)欄自動(dòng)滑動(dòng)到對應視圖
3.滑動(dòng)的到視圖對應分頁(yè)欄自動(dòng)顯示選中樣式

效果圖

上代碼

wxml

<view class="tapNav">
 <view class="{{tabArr.tabCurrentIndex==0?'active':''}}" data-index="0" bindtap="veHandle">分頁(yè)標簽1</view>
 <view class="{{tabArr.tabCurrentIndex==1?'active':''}}" data-index="1" bindtap="veHandle">分頁(yè)標簽2</view>
 <view class="{{tabArr.tabCurrentIndex==2?'active':''}}" data-index="2" bindtap="veHandle">分頁(yè)標簽3</view>
</view>
<swiper id="swiper" indicator-dots="{{indicatorDots}}"
 autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}" current="{{current}}" bindchange="swiperChange">
 <block wx:for="{{imgUrls}}">
 <swiper-item id="swiper-item">
  <image id="imgae" src="{{item}}" class="slide-image" width="355" height="150"/>
 </swiper-item>
 </block>

</swiper>

wxss

/*
1.橫向排列分頁(yè)標簽
2.每個(gè)分頁(yè)標簽各占1/3
*/
.tapNav {
 display: flex;
 flex-direction: row;
}
.tapNav view{
 flex:1;
 width:200rpx;
 height:100rpx;
 text-align: center;
 line-height: 100rpx;
 font-family: "微軟雅黑";
}
/*選中樣式*/
.tapNav .active {
 color:blue;
 border-bottom:4rpx solid mediumseagreen;
}
#swiper {
 margin-top:40rpx;
}
#swiper image{
 width:100%;
}

js

//index.js
//獲取應用實(shí)例
var app = getApp()
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'
 ],
 //是否顯示面板指示點(diǎn)
 indicatorDots: true,
 //自動(dòng)播放
 autoplay: true,
 //切換時(shí)間間隔
 interval: 2000,
 //滑動(dòng)時(shí)長(cháng)
 duration: 1000,
 //存放滑動(dòng)視圖的current
 current:0,
 //分頁(yè)標簽class條件判斷的值
 tabArr:{
  tabCurrentIndex:0
 }
 },
 //事件處理函數
 //觸摸分頁(yè)標簽觸發(fā)事件
 veHandle:function(e){
 //每個(gè)分頁(yè)標簽都設置了data-index,觸摸觸發(fā)事件獲取此數值
 //用此數值替換滑動(dòng)視圖的current
 //用此數值替換分頁(yè)標簽class判斷的值
 console.log(e.target.dataset.index)
 var currentIndex = e.target.dataset.index
 this.setData({
  current:currentIndex,
  "tabArr.tabCurrentIndex":currentIndex
 })
 },
 //通過(guò)滑塊視圖的current改變觸發(fā)事件
 swiperChange:function(e){
 //獲取視圖滑塊當前的current
 //用此數值替換分頁(yè)標簽的current的值
 console.log(e.detail.current)
 var swiperCurrent = e.detail.current;
 this.setData({
  'tabArr.tabCurrentIndex':swiperCurrent
 })
 },
 onLoad: function () {
 console.log('onLoad')
 }
})

免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng )、來(lái)自互聯(lián)網(wǎng)轉載和分享為主,文章觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權請聯(lián)系站長(cháng)郵箱:ts@56dr.com進(jìn)行舉報,并提供相關(guān)證據,一經(jīng)查實(shí),將立刻刪除涉嫌侵權內容。

亚洲成在人线在线播放无码| 国产精品毛片大码女人| 无码人妻丰满熟妇区10P| 免费人妻无码不卡中文字幕系列| 日本午夜精品一区二区三区电影| 美国少妇性XXXX另类|