您好,欢迎访问一九零五行业门户网

微信小程序开发之顶部导航栏实例

这篇文章主要介绍了微信小程序 开发之顶部导航栏实例代码的相关资料,需要的朋友可以参考下
微信小程序 开发之顶部导航栏
需求:顶部导航栏
效果图:
wxml:
<!--导航条--> <view class="navbar"> <text wx:for="{{navbar}}" data-idx="{{index}}" class="item {{currenttab==index ? 'active' : ''}}" wx:key="unique" bindtap="navbartap">{{item}}</text> </view> <!--首页--> <view hidden="{{currenttab!==0}}"> tab_01 </view> <!--搜索--> <view hidden="{{currenttab!==1}}"> tab_02 </view> <!--我--> <view hidden="{{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 }) } })
运行:
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
以上就是微信小程序开发之顶部导航栏实例的详细内容。
其它类似信息

推荐信息