這篇文章主要介紹了微信小程序怎么實現頂部普通選項卡非swiper效果,具有一定借鑒價值,需要的朋友可以參考下。希望大家閱讀完這篇文章后大有收獲。下面讓小編帶著大家一起了解一下。
創(chuàng)新互聯(lián)公司專注于企業(yè)全網整合營銷推廣、網站重做改版、嵐皋網站定制設計、自適應品牌網站建設、H5技術、商城建設、集團公司官網建設、成都外貿網站制作、高端網站制作、響應式網頁設計等建站業(yè)務,價格優(yōu)惠性價比高,為嵐皋等各大城市提供網站開發(fā)制作服務。
背景:前段時間寫了一個搶紅包小程序,里面涉及到了頂部選項卡,把它抽了出來。
效果圖:
下面直接上代碼:
wxml:
<view class="navbar"> <text wx:for="{{navbar}}" data-index="{{index}}" class="item {{currentIndex==index?'active':''}}" bindtap="navbarTab" wx:key="unique">{{item}}</text> </view> <view hidden="{{currentIndex!==0}}"> </view> <view hidden="{{currentIndex!==1}}"> </view>
wxss:
.navbar{ display: flex; width: 100%; flex-direction: row; line-height: 80rpx; position: fixed; top: 0; } .navbar .item{ flex: auto; font-size: 30rpx; text-align: center; background: #fff; font-weight: bold; } .navbar .item.active{ color: #36DB2C; position: relative; } .navbar .item.active::after{ content: ""; display: block; position: absolute; height: 4rpx; bottom: 0; left: 0; right: 0; background: #36DB2C; }
js:
data: { navbar: ["我發(fā)出的", "我收到的"], currentIndex: 0,//tabbar索引 }, navbarTab: function (e) { this.setData({ currentIndex: e.currentTarget.dataset.index }); },
感謝你能夠認真閱讀完這篇文章,希望小編分享微信小程序怎么實現頂部普通選項卡非swiper效果內容對大家有幫助,同時也希望大家多多支持創(chuàng)新互聯(lián),關注創(chuàng)新互聯(lián)行業(yè)資訊頻道,遇到問題就找創(chuàng)新互聯(lián),詳細的解決方法等著你來學習!
網站名稱:微信小程序怎么實現頂部普通選項卡非swiper效果
網站路徑:http://aaarwkj.com/article16/igdggg.html
成都網站建設公司_創(chuàng)新互聯(lián),為您提供關鍵詞優(yōu)化、Google、微信公眾號、網站改版、網站內鏈、用戶體驗
聲明:本網站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)