小程序?qū)崿F(xiàn)tab標(biāo)簽頁(yè)
本文實(shí)例為大家分享了小程序?qū)崿F(xiàn)tab標(biāo)簽頁(yè)的具體代碼,供大家參考,具體內(nèi)容如下
頁(yè)面效果:
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%;"> <!-- 頁(yè)面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;"> 頁(yè)面1 </view> </scroll-view> </view> </swiper-item> </block> <!-- 頁(yè)面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;"> 頁(yè)面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({ /** * 頁(yè)面的初始數(shù)據(jù) */ data: { tabs: [ {label:'訪客', index: 0}, {label:'工作人員', index: 1} ], currentTab:0 }, /** * 生命周期函數(shù)--監(jiān)聽(tīng)頁(yè)面加載 */ onLoad: function (options) { }, /** * 生命周期函數(shù)--監(jiān)聽(tīng)頁(yè)面初次渲染完成 */ onReady: function () { }, /** * 生命周期函數(shù)--監(jiān)聽(tīng)頁(yè)面顯示 */ 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 }) } }, //滑動(dòng)切換 swiperTab: function (e) { var that = this; that.setData({ currentTab: e.detail.current }); } })
為大家推薦現(xiàn)在關(guān)注度比較高的微信小程序教程一篇:《微信小程序開(kāi)發(fā)教程》小編為大家精心整理的,希望喜歡。
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- 微信小程序?qū)崿F(xiàn)動(dòng)態(tài)改變view標(biāo)簽寬度和高度的方法【附demo源碼下載】
- 微信小程序?qū)崿F(xiàn)點(diǎn)擊按鈕修改view標(biāo)簽背景顏色功能示例【附demo源碼下載】
- 微信小程序使用scroll-view標(biāo)簽實(shí)現(xiàn)自動(dòng)滑動(dòng)到底部功能的實(shí)例代碼
- 微信小程序 <swiper-item>標(biāo)簽傳入數(shù)據(jù)
- 微信小程序基于slider組件動(dòng)態(tài)修改標(biāo)簽透明度的方法示例
- 微信小程序?qū)崿F(xiàn)點(diǎn)擊按鈕移動(dòng)view標(biāo)簽的位置功能示例【附demo源碼下載】
- 微信小程序button標(biāo)簽open-type屬性原理解析
- 微信小程序 基礎(chǔ)知識(shí)css樣式media標(biāo)簽
- 如何去除富文本中的html標(biāo)簽及vue、react、微信小程序中的過(guò)濾器
- 微信小程序中input標(biāo)簽詳解及簡(jiǎn)單實(shí)例
相關(guān)文章
前端實(shí)現(xiàn)文本超出指定行數(shù)顯示"展開(kāi)"和"收起"效果詳細(xì)步驟
本文介紹如何使用JavaScript原生代碼實(shí)現(xiàn)文本折疊展開(kāi)效果,并提供方法指導(dǎo)如何在Vue或React等框架中修改實(shí)現(xiàn),詳細(xì)介紹了創(chuàng)建整體框架、設(shè)置樣式及利用JS控制元素的步驟,文中通過(guò)代碼介紹的非常詳細(xì),需要的朋友可以參考下2024-10-10JS圖片預(yù)加載三種實(shí)現(xiàn)方法解析
這篇文章主要介紹了JS圖片預(yù)加載三種實(shí)現(xiàn)方法解析,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-05-05讓JavaScript擁有類(lèi)似Lambda表達(dá)式編程能力的方法
在前幾天的博文中我發(fā)布了一個(gè)可以自定義頁(yè)碼呈現(xiàn)方式的組件,有C#和JavaScript兩個(gè)版本。2010-09-09javascript函數(shù)以及基礎(chǔ)寫(xiě)法100多條實(shí)用整理
100多個(gè)很有用的JavaScript函數(shù)以及基礎(chǔ)寫(xiě)法匯總,在項(xiàng)目開(kāi)發(fā)中經(jīng)常會(huì)使用到,本文整理了一些,希望對(duì)你們有幫助2013-01-01