|
底部3-5個選項的底部導航欄,目前在移動端上是主流布局之一
因此騰訊官方特地做了,可以通過設置,就可以做出了一個底部的導航欄
但是通過設置的這個底部的導航欄,功能上比較固定,它必須要設置與它對應的一個頁面,而且并不能滑動。
在業務上,有時候(hou)會比(bi)較限(xian)制,并不能(neng)完全滿足所需。
因此自(zi)定(ding)義就有這(zhe)個必要性
下面(mian)介紹這個仿Android fragment可滑動的底部導(dao)航欄(lan)如何實現
下面介紹這個(ge)仿android fragment可滑動(dong)的底部(bu)導航欄如何實現(xian)
項目(mu)最終(zhong)效果圖:

wxml:
-
<swiper current="{{currentTab}}" class="swiper-box" duration="300" style="height:{{winHeight - 51}}px" bindchange="bindChange">
-
-
-
<swiper-item>
-
<scroll-view class="hot-box" scroll-y="true" upper-threshold="50" lower-threshold="100" bindscrolltolower="scrolltolower">
-
-
-
<view class="themes-list">
-
<view class="themes-list-box" wx:for="{{datalists}}">
-
<view class="themes-list-main">
-
<view class="themes-list-name">{{item}}</view>
-
</view>
-
</view>
-
</view>
-
</scroll-view>
-
</swiper-item>
-
-
-
<swiper-item>
-
<scroll-view class="hot-box" scroll-y="true" upper-threshold="50" lower-threshold="100" bindscrolltolower="scrolltolower">
-
-
-
<view class="themes-list">
-
<view class="themes-list-box" wx:for="{{reslists}}">
-
<view class="themes-list-main">
-
<view class="themes-list-name">{{item}}</view>
-
</view>
-
</view>
-
</view>
-
</scroll-view>
-
</swiper-item>
-
-
-
<swiper-item>
-
<scroll-view class="hot-box" scroll-y="true" upper-threshold="50" lower-threshold="100" bindscrolltolower="scrolltolower">
-
-
-
<view class="themes-list">
-
<view class="themes-list-box" wx:for="{{datalists}}">
-
<view class="themes-list-main">
-
<view class="themes-list-name">{{item}}</view>
-
</view>
-
</view>
-
</view>
-
</scroll-view>
-
</swiper-item>
-
-
-
<swiper-item>
-
<scroll-view class="hot-box" scroll-y="true" upper-threshold="50" lower-threshold="100" bindscrolltolower="scrolltolower">
-
-
-
<view class="themes-list">
-
<view class="themes-list-box" wx:for="{{reslists}}">
-
<view class="themes-list-main">
-
<view class="themes-list-name">{{item}}</view>
-
</view>
-
</view>
-
</view>
-
</scroll-view>
-
</swiper-item>
-
</swiper>
-
-
-
<view class="swiper-tab">
-
<view class="swiper-tab-list {{currentTab==0 ? 'active' : ''}}" data-current="0" bindtap="swichNav">
-
<view class="swiper-tab-img"><image class="img" src="{{currentTab==0 ? iconlists[0].focus: iconlists[0].normal}}"></image></view>
-
<view>frag01</view>
-
</view>
-
<view class="swiper-tab-list {{currentTab==1 ? 'active' : ''}}" data-current="1" bindtap="swichNav">
-
<view class="swiper-tab-img"><image class="img" src="{{currentTab==1 ? iconlists[1].focus: iconlists[1].normal}}"></image></view>
-
<view>frag02</view>
-
</view>
-
<view class="swiper-tab-list {{currentTab==2 ? 'active' : ''}}" data-current="2" bindtap="swichNav">
-
<view class="swiper-tab-img"><image class="img" src="{{currentTab==2 ? iconlists[2].focus: iconlists[2].normal}}"></image></view>
-
<view>frag03</view>
-
</view>
-
<view class="swiper-tab-list {{currentTab==3 ? 'active' : ''}}" data-current="3" bindtap="swichNav">
-
<view class="swiper-tab-img"><image class="img" src="{{currentTab==3 ? iconlists[3].focus: iconlists[3].normal}}"></image></view>
-
<view>frag04</view>
-
</view>
-
</view>
wxss:
-
-
.swiper-box {
-
display: block;
-
height: 100%;
-
width: 100%;
-
overflow: hidden;
-
}
-
.hot-box {
-
display: block;
-
height: 100%;
-
font-family: Helvetica;
-
}
-
-
.themes-list {
-
background: #fff;
-
display: block;
-
margin-bottom: 20px;
-
}
-
.themes-list-box {
-
display: block;
-
position: relative;
-
padding: 16px 20px;
-
border-bottom: 1px solid #f2f2f2;
-
}
-
.themes-list-main {
-
margin-left: 1px;
-
}
-
.themes-list-name {
-
font-size: 14px;
-
color: #444;
-
height: 20px;
-
line-height: 20px;
-
overflow: hidden;
-
}
-
-
.swiper-tab {
-
height: 50px;
-
background: #fff;
-
display: flex;
-
position: relative;
-
z-index: 2;
-
flex-direction: row;
-
justify-content: center;
-
align-items: center;
-
border-top: 1px solid #ccc;
-
}
-
.swiper-tab-list {
-
margin: 0 20px;
-
padding: 0 4px;
-
font-size: 28rpx;
-
font-family: Helvetica;
-
}
-
.active {
-
-
color: #FFCC00;
-
}
-
.swiper-tab-img {
-
text-align: center;
-
}
-
.img {
-
width:23px;
-
height: 23px;
-
}
js:
-
Page( {
-
data: {
-
winWidth: 0,
-
winHeight: 0,
-
currentTab: 0,
-
datalists : [
-
"習近(jin)平主持中央財經(jing)領(ling)導小組第十五次(ci)會議",
-
"李克(ke)強打(da)叉的“萬(wan)里(li)審批圖”成歷史",
-
"新疆(jiang)自治(zhi)區(qu)舉(ju)行反(fan)恐維穩誓師大會",
-
"朝鮮代表團抵達馬來西亞處理金(jin)正男(nan)遇害案",
-
"寶馬車(che)禍案肇事(shi)者二次精(jing)神鑒(jian)定:案發(fa)為精(jing)神病狀態",
-
"朝鮮代表團抵達馬(ma)來西亞處理金正男(nan)遇害案",
-
"寶(bao)馬車禍案肇事者(zhe)二(er)次精(jing)(jing)神鑒定:案發為精(jing)(jing)神病狀態",
-
"朝鮮代(dai)表團抵達(da)馬(ma)來西亞處理(li)金正男遇害案(an)",
-
"寶馬(ma)車禍案肇(zhao)事者(zhe)二(er)次精(jing)神(shen)鑒定:案發為精(jing)神(shen)病狀態",
-
"朝鮮代表團抵達馬來西亞處理(li)金正(zheng)男(nan)遇害案(an)",
-
"寶(bao)馬(ma)車禍案肇事者二次精神(shen)鑒定:案發為精神(shen)病狀態(tai)",
-
"砸鍋賣鐵(tie)!索尼(ni)是在(zai)走(zou)向毀滅(mie) 還是在(zai)奔向新生(sheng)?"
-
],
-
reslists:["hello","thank you for your read","if u feel good","can u give me good?"],
-
iconlists:[
-
{normal:"../../images/wp.png",focus:"../../images/wpselect.png"},
-
{normal:"../../images/ss.png",focus:"../../images/ssselect.png"},
-
{normal:"../../images/hc.png",focus:"../../images/hcselect.png"},
-
{normal:"../../images/my.png",focus:"../../images/myselect.png"},
-
]
-
},
-
onLoad: function( options ) {
-
var that = this;
-
-
wx.getSystemInfo( {
-
success: function( res ) {
-
that.setData( {
-
winWidth: res.windowWidth,
-
winHeight: res.windowHeight
-
});
-
}
-
});
-
},
-
-
-
-
bindChange: function( e ) {
-
var that = this;
-
that.setData( { currentTab: e.detail.current });
-
},
-
-
-
-
swichNav: function( e ) {
-
console.log(e)
-
var that = this;
-
if( this.data.currentTab === e.currentTarget.dataset.current ) {
-
-
return false;
-
} else {
-
that.setData( {
-
currentTab: e.currentTarget.dataset.current
-
})
-
}
-
-
}
-
})
|