微信小程序自定义tabbar组件之中间按钮凸起

和我前面一篇文章差不多的, 只不过逻辑有点不同,直接上效果和代码吧

有个注意事项:如果用次调转出了小程序界面(如支付成功的界面,底部的隐藏tabbar会无法隐藏)

这里是github代码的路径,直接可以拉下来。
github代码拉取地址:https://github.com/lzn961136007/tabbar.git
在这里插入图片描述
先来一个模板文件,我的图片放在模板文件里
wxml

<view class="tabbar_box {
  {isIphoneX?'iphoneX-height':''}}" style="background-color:{
  {tabbar.backgroundColor}}">
  <block wx:for="{
  {tabbar.list}}" wx:key="{
  {item.pagePath}}">

    <navigator wx:if="{
  {item.isSpecial == true}}" class="tabbar_nav" hover-class="none" url="{
  {item.pagePath}}" style="color:{
  {tabbar.selectedColor}}" open-type="navigate">
      <view class='special-wrapper'><image class="tabbar_icon" src="{
  {item.iconPath}}"></image></view>
      <image class='special-text-wrapper'></image>
      <text>{
  {item.text}}</text>
    </navigator>
    
    <navigator wx:else class="tabbar_nav" hover-class="none" url="{
  {item.pagePath}}" style="color:{
  {item.selected ? tabbar.selectedColor : tabbar.color}}" open-type="switchTab">
      <image class="tabbar_icon" src="{
  {item.selected ? item.selectedIconPath : item.iconPath}}"></image>
      <text>{
  {item.text}}</text>
    </navigator>
  </block>
</view>

wxss

.tabbar_box{
    display: flex;
    flex-direction: row;
    justify-content: space-around;
    position: fixed;
    bottom: 0;
    left: 0;
    z-index: 999;
    width:
  • 11
    点赞
  • 40
    收藏
    觉得还不错? 一键收藏
  • 126
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 126
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值