您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

小程序中顶部导航栏示例代码

2024/12/24 22:19:27发布19次查看
微信小程序 开发之顶部导航栏
需求:顶部导航栏
wxml:
<!--导航条--> <view class="navbar"> <text wx:for="pw_navbar" data-idx="pw_index" class="item pw_currenttab==index ? 'active' : ''" wx:key="unique" bindtap="navbartap">pw_item</text> </view> <!--首页--> <view hidden="pw_currenttab!==0"> tab_01 </view> <!--搜索--> <view hidden="pw_currenttab!==1"> tab_02 </view> <!--我--> <view hidden="pw_currenttab!==2"> tab_03 </view>
wxss:
page{ display: flex; flex-direction: column; height: 100%; } .navbar{ flex: none; display: flex; background: #fff; } .navbar .item{ position: relative; flex: auto; text-align: center; line-height: 80rpx; } .navbar .item.active{ color: #ffcc00; } .navbar .item.active:after{ content: ""; display: block; position: absolute; bottom: 0; left: 0; right: 0; height: 4rpx; background: #ffcc00; }
js:
var app = getapp() page({ data: { navbar: ['首页', '搜索', '我'], currenttab: 0 }, navbartap: function(e){ this.setdata({ currenttab: e.currenttarget.dataset.idx }) } })
以上就是小程序中顶部导航栏示例代码的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product