小程序?qū)崿F(xiàn)tab標(biāo)簽頁
本文實例為大家分享了小程序?qū)崿F(xiàn)tab標(biāo)簽頁的具體代碼,供大家參考,具體內(nèi)容如下
頁面效果:

HTML:
<view wx:if="{{userType==0}}" style="height:100%">
<view class="tab_box" style="width: 100%">
<view class="tabs_v">
<block wx:for="{{tabs}}" wx:for-item="item" wx:key="index">
<view class="tab_v {{index<1?'tab_nature':'tab_course'}}" bindtap='changeCurrentTab_' data-index='{{index}}'
data-current='{{index}}'>
<text class="tab_txt {{currentTab==index? 'tab_v_active' : ''}}">{{item.label}}</text>
</view>
</block>
</view>
</view>
<!-- tab 容器 -->
<view class="tabWrap">
<swiper class="" current="{{currentTab}}" duration="300" bindchange="swiperTab" style="width:100%;height:100%;">
<!-- 頁面1 -->
<block>
<swiper-item style="width:100%;height:100%;">
<view class="" style="width:100%;height:100%;">
<scroll-view style="width:100%;height:100%;" scroll-y="true" bindscrolltolower='scrollToLower'
bindscrolltoupper='scrollToUpper' lower-threshold='30' upper-threshold='30'>
<view style="width:100%;height:auto;">
頁面1
</view>
</scroll-view>
</view>
</swiper-item>
</block>
<!-- 頁面2 -->
<block>
<swiper-item style="width:100%;height:100%;">
<view class="" style="width:100%;height:100%;">
<scroll-view style="width:100%;height:100%;" scroll-y="true" bindscrolltolower='scrollToLower'
bindscrolltoupper='scrollToUpper' lower-threshold='30' upper-threshold='30'>
<view style="width:100%;height:auto;">
頁面2
</view>
</scroll-view>
</view>
</swiper-item>
</block>
</swiper>
</view>
</view>
CSS:
/* tab */
.tab_box{
height: 50px;
display: flex;
flex-direction: row;
background-color: #fff;
border-bottom: 1px solid #E5E5E5;
margin-bottom: 15px;
}
.tabs_v{
width: 100%;
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
}
.tab_v{
width: 50%;
text-align: center;
}
.tab_txt{
border-bottom: 2px solid transparent;
padding-bottom: 14px;
color: #999999;
}
.tab_v_active{
border-bottom: 2px solid #00C6AC;
color: #00C6AC;
font-weight: bold;
}
/* 容器 */
.tabWrap{
width: 100%;
height: calc(100% - 67px);
position: relative;
border-bottom: 1px solid #e6e6e6;
}
JS:
Page({
/**
* 頁面的初始數(shù)據(jù)
*/
data: {
tabs: [
{label:'訪客', index: 0},
{label:'工作人員', index: 1}
],
currentTab:0
},
/**
* 生命周期函數(shù)--監(jiān)聽頁面加載
*/
onLoad: function (options) {
},
/**
* 生命周期函數(shù)--監(jiān)聽頁面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函數(shù)--監(jiān)聽頁面顯示
*/
onShow: function () {
},
// tab切換
changeCurrentTab_(e){
let that = this
if (that.data.currentTab === e.currentTarget.dataset.current){
return false
}else{
that.setData({
currentTab: e.currentTarget.dataset.current
})
}
},
//滑動切換
swiperTab: function (e) {
var that = this;
that.setData({
currentTab: e.detail.current
});
}
})
為大家推薦現(xiàn)在關(guān)注度比較高的微信小程序教程一篇:《微信小程序開發(fā)教程》小編為大家精心整理的,希望喜歡。
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- 微信小程序?qū)崿F(xiàn)動態(tài)改變view標(biāo)簽寬度和高度的方法【附demo源碼下載】
- 微信小程序?qū)崿F(xiàn)點擊按鈕修改view標(biāo)簽背景顏色功能示例【附demo源碼下載】
- 微信小程序使用scroll-view標(biāo)簽實現(xiàn)自動滑動到底部功能的實例代碼
- 微信小程序 <swiper-item>標(biāo)簽傳入數(shù)據(jù)
- 微信小程序基于slider組件動態(tài)修改標(biāo)簽透明度的方法示例
- 微信小程序?qū)崿F(xiàn)點擊按鈕移動view標(biāo)簽的位置功能示例【附demo源碼下載】
- 微信小程序button標(biāo)簽open-type屬性原理解析
- 微信小程序 基礎(chǔ)知識css樣式media標(biāo)簽
- 如何去除富文本中的html標(biāo)簽及vue、react、微信小程序中的過濾器
- 微信小程序中input標(biāo)簽詳解及簡單實例
相關(guān)文章
javascript實現(xiàn)的圖片預(yù)覽和上傳功能示例【兼容IE 9】
這篇文章主要介紹了javascript實現(xiàn)的圖片預(yù)覽和上傳功能,結(jié)合實例形式分析了javascrpt圖片預(yù)覽和上傳功能相關(guān)實現(xiàn)技巧與操作注意事項,需要的朋友可以參考下2020-05-05
JAVASCRIPT車架號識別/驗證函數(shù)代碼 汽車車架號驗證程序
偶然中在CSDN里找到C#版的驗證程序,因此改編了一版JS版本,相信會對大家有用2012-01-01
javascript正則表達(dá)式之search()用法實例
這篇文章主要介紹了javascript正則表達(dá)式之search()用法,實例分析了search()的使用技巧,需要的朋友可以參考下2015-01-01
JavaScript實現(xiàn)省市聯(lián)動過程中bug的解決方法
這篇文章主要為大家詳細(xì)介紹了解決JavaScript實現(xiàn)省市聯(lián)動過程中的bug,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-12-12
JavaScript設(shè)計模式之原型模式(Object.create與prototype)介紹
這篇文章主要介紹了JavaScript設(shè)計模式之原型模式(Object.create與prototype)介紹,原型模式指使用原型實例來拷貝、創(chuàng)建新的可定制的對象,新建的對象,不需要知道原對象創(chuàng)建的具體過程,需要的朋友可以參考下2014-12-12
javascript函數(shù)自動執(zhí)行常用方法匯總
本文給大家匯總介紹了3種javascript函數(shù)自動執(zhí)行的常用方法,非常的簡單實用,有需要的小伙伴可以參考下2016-03-03

