uni-app如果自定义tabbar实现底部样式有凸起效果,背景带圆角

想要实现的效果、

大部分可以参考这一篇文章

小程序弹出框是没办法遮挡住底部的tabbar的,解决的办法是使用自定义tabbar。。uni-app小程序如何自定义tabbar-CSDN博客

我们只要改下index.wxml和index. wxs的代码就行了

复制代码
<view class="tab-bar">
  <block wx:for="{{list}}" wx:key="index">
    <view class="tab-bar-item" data-path="{{item.pagePath}}" data-index="{{index}}" bindtap="switchTab">
       <view class="special-image" wx:if="{{selected === index}}">
              <image class="special-image-pic" mode="aspectFit" src="{{item.selectedIconPath}}" mode="aspectFit"></image>
       </view>
       <image class="item-image" mode="aspectFit" src="{{item.iconPath}}" mode="aspectFit" wx:else></image>
      <view class="tab-text" style="color: {{selected === index ? selectedColor : color}}">{{item.text}}</view>
    </view>
  </block>
</view>
复制代码
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 96rpx;
  background: white;
  display: flex;
  padding-bottom: env(safe-area-inset-bottom);
  border-radius:32rpx 32rpx 0 0;
  padding-top:22rpx;
}

.tab-bar-border {
  background-color: rgba(0, 0, 0, 0.33);
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 2rpx;
  transform: scaleY(0.5);
}

.tab-bar-item {
  flex: 1;
  text-align: center;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  position:relative;
}

.tab-bar-item .item-image {
  width: 46rpx;
  height: 46rpx;
  position: absolute;
  top: 0;
}
.tab-bar-item .special-image {
  position: absolute;
  top: -50rpx;
  left: 35rpx;
  width: 150rpx;
  height: 150rpx;
  text-align: center;
  box-sizing: border-box;
}
.tab-bar-item .special-image .special-image-pic {
  width: 100%;
  height: 100%;
}

.tab-bar-item .tab-text {
  margin-top: 4rpx;
}

.tab-bar-item .special-text {
  margin-top: 44rpx
}

.tab-bar-item .tab-text {
  font-size: 28rpx;
  position:absolute;
  bottom:0;
}
相关推荐
快起来搬砖了2 小时前
创意实现!在uni-app小程序商品详情页轮播中嵌入视频播放功能
小程序·uni-app·商城
qq_530245192 小时前
uniapp自定义底部tabBar
uni-app·自定义tabbar
酷盖机车男2 小时前
封装轮播图 (因为基于微博小程序,语法可能有些出入,如需使用需改标签)
前端·javascript·小程序·uni-app
Jiaberrr3 小时前
uniapp实战教程:如何封装一个可复用的表单组件
javascript·笔记·前端框架·uni-app·表单
用户0527277021173 小时前
Uni app 离线 OCR android 实现 MLKIT
uni-app
雪芽蓝域zzs3 小时前
uni-app #ifdef #ifndef #endif的使用和区别
uni-app
Jiaberrr3 小时前
uniapp视频禁止用户推拽进度条并保留进度条显示的解决方法——方案二
前端·javascript·uni-app·音视频
Jiaberrr5 小时前
uniapp视频禁止用户推拽进度条并保留进度条显示的解决方法——方案一
前端·javascript·微信小程序·uni-app·音视频
夏天想10 小时前
uni-app+vue3+pina实现全局加载中效果,自定义全局变量和函数可供所有页面使用
前端·javascript·uni-app