这篇文章主要为大家详细介绍了微信小程序实现顶部普通选项卡效果,非swiper,具有一定的参考价值▽△▷,感兴趣的小伙伴们可以参考一下
背景:前段时间写了一个抢红包小程序,通州市小程序开发哪家好里面涉及到了顶部选项卡,把它抽了出来。阿城市小程序制作公司phpMyAdmin[宁波seo推广公司]
效果图◇▲=•:
下面直接上代码:
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: ["我发出的", "我收到的"•△;]=…••, currentIndex▷▷: 0,//tabbar索引 }▽▷▪, navbarTab▼▪=•: function (e) { this▪▽◇◁.setData({ currentIndex: e.currentTarget■•.dataset.index })•○; },
以上是实现过程基本代码▽•,省去了中间内容的代码▼△☆○。顶部个数是循环出来的,郏县小程序开发哪家好可以根据自己的实际需求设置。
以上就是微信小程序如何实现顶部普通选项卡非swiper效果的实例的详细内容,更多请关注久澳传媒编程栏目其它相关文章!
*请认真填写需求信息,我们会在24小时内与您取得联系。