微信小程序自定义的导航栏

目录

项目场景

效果图 

解决方案

具体的代码

wxml

wxss

素材库

题外话


项目场景

一个小程序可以拥有用户端和审批端,但微信原生小程序规定只能有一个tabar在小程序中,但是一旦是多端口的小程序,又需要tabar来跳转页面那该怎么办呢?这里介绍一种比较简单的方法。


效果图 


问题描述

小程序自带的tabar(在json文件中设置)

自制的简易tabar

 


解决方案

核心思想:设计方案是设置一个盒子永远沉在页面的最底部(无论这个页面有多高),并且这个盒子与页面的内容位于同一个图层(无遮挡)。然后将矢量图标以及提示文件放如盒子里做成上图的样式。

具体的代码

wxml

<view class="container">
       <view class="container_content">
              <view class="box">
              //里面是你的内容
              </view>
              <!-- 简易导航栏 -->
              <view class="tabar">
                            <view class='goApprovalButton' bindtap="goApprovalPage">
                                   <image src="../../icon/approval(1).png" style="width:         
                                    40px; height: 40px; margin-top: 5px;"></image>
                                   <view class="button_content">待审批</view>
                            </view>
                            <view class="goPassButton" bindtap="goPassPage">
                                   <image src="../../icon/pass(1).png" style="width: 40px; 
                                    height: 40px; margin-top: 5px;"></image>
                                   <view class="button_content">已通过</view>
                            </view>
                            <view class="goRejectButton" bindtap="goRejectPage">
                                   <image src="../../icon/reject(1).png" style="width: 
                                   40px; height: 40px; margin-top: 5px;"></image>
                                   <view class="button_content">已驳回</view>
                            </view>
                            <view class="goEndingButton" bindtap="goEndingPage">
                                   <image src="../../icon/end.png" style="width: 40px; 
                                    height: 40px; margin-top: 5px;"></image>
                                   <view class="button_content">已结束</view>
                            </view>
              </view>
       </view>
</view>

wxss

   .goApprovalButton{
         position: absolute;
         bottom:0px ;
         left: 0px;
         color:#FFFFFF;
         background-color:#FFFFFF;
         border-top: 2px solid grey;
         width: 25%;
         height: 70px;
         text-align:center;
         margin-top: 10px;
  }
  .goPassButton{
         position: absolute;
         bottom:0px ;
         left: 25%;
         color:#FFFFFF;
         background-color:#FFFFFF;
         border-top: 2px solid grey;
         width: 25%;
         height: 70px;
         text-align:center;
         margin-top: 10px;
  }
  
  .goRejectButton{
         position: absolute;
         bottom:0px ;
         left: 50%;
         color:#FFFFFF;
         background-color:#FFFFFF;
         border-top: 2px solid grey;
         width: 25%;
         height: 70px;
         text-align:center;
         margin-top: 10px;
         
  }
  .goEndingButton{
         position: absolute;
         bottom: 0px;
         left: 75%;
         color:#FFFFFF;
         background-color: white;
         border-top: 2px solid grey;
         width: 25%;
         height: 70px;
         text-align:center;
         margin-top: 10px;
  }
  .button_content{
         font-size: 15px;
         color: black;
  }
  
  .container{
         position: relative;
  }
  
  .container_content{
         position: relative;
         min-height: 100vh;
         box-sizing: border-box;
         padding-bottom: 60rpx;
         padding-top: 0rpx;
  }
  
  .tabar{
         width: 100%;
         text-align: center;
         letter-spacing: 4rpx;
         position: absolute;
         bottom: 0;
  
  }
  

素材库

此外,很多矢量图片可以到阿里巴巴矢量图标库里查找,地址我放在下面了。

iconfont-阿里巴巴矢量图标库


题外话

如果有疑问欢迎大家留言讨论,你如果觉得这篇文章对你有帮助可以给我一个免费的赞吗?我们之间的交流是我最大的动力!

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

hiddenSharp429

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值