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

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

2024/4/27 6:25:44发布6次查看
这篇文章主要介绍了微信小程序 开发之顶部导航栏实例代码的相关资料,需要的朋友可以参考下
微信小程序 开发之顶部导航栏
需求:顶部导航栏
效果图:
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 }) } })
运行:
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
以上就是微信小程序开发之顶部导航栏实例的详细内容。
该用户其它信息

VIP推荐

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