免费国产欧美国日产_少妇AV一区二区三区无码_蜜桃精品av无码喷奶水小说_jk18禁网站视频_精产国品一二三级产品区别_被夫の上司に犯波多野结衣_78m成人手机免费看_最爽最刺激18禁视频_偷偷色噜狠狠狠狠的777米奇

易優(yōu)GEO 重磅上線 ~ 一站式GEO優(yōu)化工具,讓豆包、文心一言、DeepSeek 在回答中主動(dòng)推薦你的品牌,搶占AI流量入口!  點(diǎn)擊查看

小程序模板網(wǎng)

微信小程序之頂部導(dǎo)航欄

發(fā)布時(shí)間:2017-12-01 15:20 所屬欄目:小程序開(kāi)發(fā)教程

需求:頂部導(dǎo)航欄效果圖:wxml:!--導(dǎo)航條-- view class="navbar" text wx:for="{{navbar}}" data-idx="{{index}}" class="item {{currentTab==index ? 'active' : ''}}" wx:key ...

 
 
 

需求:頂部導(dǎo)航欄 
效果圖: 

wxml:

 

						
  1. <!--導(dǎo)航條-->
  2. <view class="navbar">
  3. <text wx:for="{{navbar}}" data-idx="{{index}}" class="item {{currentTab==index ? 'active' : ''}}" wx:key="unique" bindtap="navbarTap">{{item}}</text>
  4. </view>
  5.  
  6. <!--首頁(yè)-->
  7. <view hidden="{{currentTab!==0}}">
  8. tab_01
  9. </view>
  10.  
  11. <!--搜索-->
  12. <view hidden="{{currentTab!==1}}">
  13. tab_02
  14. </view>
  15.  
  16. <!--我-->
  17. <view hidden="{{currentTab!==2}}">
  18. tab_03
  19. </view>

wxss:

 

						
  1. page{
  2. display: flex;
  3. flex-direction: column;
  4. height: 100%;
  5. }
  6. .navbar{
  7. flex: none;
  8. display: flex;
  9. background: #fff;
  10. }
  11. .navbar .item{
  12. position: relative;
  13. flex: auto;
  14. text-align: center;
  15. line-height: 80rpx;
  16. }
  17. .navbar .item.active{
  18. color: #FFCC00;
  19. }
  20. .navbar .item.active:after{
  21. content: "";
  22. display: block;
  23. position: absolute;
  24. bottom: 0;
  25. left: 0;
  26. right: 0;
  27. height: 4rpx;
  28. background: #FFCC00;
  29. }

js:

 

						
  1. var app = getApp()
  2. Page({
  3. data: {
  4. navbar: ['首頁(yè)', '搜索', '我'],
  5. currentTab: 0
  6. },
  7. navbarTap: function(e){
  8. this.setData({
  9. currentTab: e.currentTarget.dataset.idx
  10. })
  11. }
  12. })

運(yùn)行: 



易優(yōu)小程序(企業(yè)版)+靈活api+前后代碼開(kāi)源 碼云倉(cāng)庫(kù):starfork
本文地址:http://www.szcjxy.com/wxmini/doc/course/18009.html 復(fù)制鏈接 如需定制請(qǐng)聯(lián)系易優(yōu)客服咨詢(xún): 點(diǎn)擊咨詢(xún)
在線客服