当前位置: 首页 > news >正文

微信程序 自定义遮罩层遮不住底部tabbar解决

一、先上效果

在这里插入图片描述

二 方法

1、自定义底部tabbar

实现:

https://developers.weixin.qq.com/miniprogram/dev/framework/ability/custom-tabbar.html 官网去抄

简单写下:在代码根目录下添加入口文件 除了js 文件的list 需要调整 其他原封不动
在这里插入图片描述

代码:
js部分

Component({data: {selected: 0,color: "#7A7E83",selectedColor: "#0081FF",list: [{  // 同app.json下的tabbar列表"iconPath": "/assets/img/build.png","selectedIconPath": "/assets/img/buildSelect.png","pagePath": "/pages/index/index","text": "淘楼"},{"iconPath": "/assets/img/my.png","selectedIconPath": "/assets/img/selectMy.png","pagePath": "/pages/my/index","text": "我的"}]},attached() {},methods: {switchTab(e) {console.log(e.currentTarget)const data = e.currentTarget.datasetconst url = data.pathwx.switchTab({url})this.setData({selected: data.index})}}
})

json

{"component": true,"usingComponents": {}
}

wxml

<!--miniprogram/custom-tab-bar/index.wxml-->
<view class="tab-bar"><view class="tab-bar-border"></view><view wx:for="{{list}}" wx:key="index" class="tab-bar-item" data-path="{{item.pagePath}}" data-index="{{index}}" bindtap="switchTab"><image src="{{selected === index ? item.selectedIconPath : item.iconPath}}"></image><view style="color: {{selected === index ? selectedColor : color}}">{{item.text}}</view></view>
</view>

wxss

  position: fixed;bottom: 0;left: 0;right: 0;height: 48px;background: white;display: flex;padding-bottom: env(safe-area-inset-bottom);z-index: 99;
}.tab-bar-border {background-color: rgba(0, 0, 0, 0.33);position: absolute;left: 0;top: 0;width: 100%;height: 1px;transform: scaleY(0.5);
}.tab-bar-item {flex: 1;text-align: center;display: flex;justify-content: center;align-items: center;flex-direction: column;
}.tab-bar-item image {width: 27px;height: 27px;
}.tab-bar-item view {font-size: 10px;
}.tab-bar {position: fixed;bottom: 0;left: 0;right: 0;height: 48px;background: white;display: flex;padding-bottom: env(safe-area-inset-bottom);z-index: 99;
}.tab-bar-border {background-color: rgba(0, 0, 0, 0.33);position: absolute;left: 0;top: 0;width: 100%;height: 1px;transform: scaleY(0.5);
}.tab-bar-item {flex: 1;text-align: center;display: flex;justify-content: center;align-items: center;flex-direction: column;
}.tab-bar-item image {width: 27px;height: 27px;
}.tab-bar-item view {font-size: 10px;
}

2、 list 的中的页面 都需要在onShow中加入一下方法

    if (typeof this.getTabBar === 'function' &&this.getTabBar()) {this.getTabBar().setData({selected: 0})}

三、遮罩层 盖住底部tabbar 自己实现一个遮罩层或者使用组件 我这儿用的组件 只需要让z-index:的值大于99999 即可

<!-- 遮罩层 -->
<van-overlay show="{{ overlayShow }}" vertical z-index="{{999999}}"><view class="overlay-content"><van-loading type="spinner">加载中...</van-loading></view>
</van-overlay>
http://www.lryc.cn/news/126867.html

相关文章:

  • Python简易部署方法
  • Spring Boot单元测试与Mybatis单表增删改查
  • 机器学习样本数据划分的典型Python方法
  • 重建与突破,探讨全链游戏的现在与未来
  • [C++] 模板template
  • [vite] 项目打包后页面空白,配置了base后也不生效
  • springboot整合kafka-笔记
  • Rust软件外包开发语言的特点
  • Spring Boot业务代码中使用@Transactional事务失效踩坑点总结
  • 知识体系总结(九)设计原则、设计模式、分布式、高性能、高可用
  • Springboot 集成Beetl模板
  • RabbitMQ查询队列使用情况和消费者详情实现
  • Spark第二课RDD的详解
  • 人工智能学习框架—飞桨Paddle人工智能
  • SElinux 导致 Keepalived 检测脚本无法执行
  • 2022年电赛C题——小车跟随行驶系统——做题记录以及经验分享
  • vscode + python
  • badgerdb里面的事务
  • C# this.Invoke(new Action(() => { /* some code */ }))用法说明
  • MongoDB:MySQL,Redis,ES,MongoDB的应用场景
  • leetcode每日一题_2682.找出转圈游戏输家
  • OpenCV之薄板样条插值(ThinPlateSpline)
  • 034_小驰私房菜_[问题复盘] Qcom平台,某些三方相机拍照旋转90度
  • 【TI-CCS笔记】工程编译配置 bin文件的编译和生成 各种架构的Post-build配置汇总
  • 深入探索Java中的File类与IO操作:从路径到文件的一切
  • Python 处理 Excel 表格的 14 个常用操作
  • PyQt有哪些主要组件?
  • 力推C语言必会题目终章(完结篇)
  • CS5263替代停产IT6561连接DP转HDMI音视频转换器ASL 集睿致远CS5263设计电路原理图
  • 数据分析 | 随机森林如何确定参数空间的搜索范围