首页 > 编程语言 >微信小程序中对custom-tab-bar高度的处理

微信小程序中对custom-tab-bar高度的处理

时间:2024-06-17 09:42:56浏览次数:14  
标签:bar tabBar 微信 custom tab scroll view

现在有个页面中由一个scroll-view组成

<!--index.wxml-->
<scroll-view scroll-y style="height: 100vh">
  <view style="height: 100%; display: flex; align-items: center; justify-content: center;">scroll-view</view>
</scroll-view>

为了使scroll-view按照预期的方式工作,需要为其动态设置高度
如果使用的是小程序内置提供的tabBar

// app.json 中 tabBar 的配置
"tabBar": {
  "position": "bottom",
  "list": [{
    "pagePath": "pages/index/index",
    "text": "首页",
    "iconPath": "/assets/icons/home.png",
    "selectedIconPath": "/assets/icons/home-selected.png"
  }, {
    "pagePath": "pages/my/my",
    "text": "我的",
    "iconPath": "/assets/icons/user.png",
    "selectedIconPath": "/assets/icons/user-selected.png"
  }]
}


不管是在 iphone6 还是 iphoneX 下,微信自动帮我们的页面处理了tabBar的高度,岁月静好,一切都works all fine!

然而,内置的tabBar往往是无法满足产品经理的奇思妙想的
那么,我们自然会切换到custom-tab-bar自己写一个


此时如图所示,custom-tab-bar 把咱们的 scroll-view 给盖住了一部分,说明我们的 scroll-view 还得减去 custom-tab-bar 的高度

height: calc(100vh - 96rpx(自定义的tabbar组件高度) - env(safe-area-inset-bottom)(适配苹果底部安全距离的高度));

首页代码修改如下

<!--index.wxml-->
<scroll-view scroll-y style="height: calc(100vh - 112rpx - env(safe-area-inset-bottom))">
  <view style="height: 100%; display: flex; align-items: center; justify-content: center;">scroll-view</view>
</scroll-view>


搞定

标签:bar,tabBar,微信,custom,tab,scroll,view
From: https://www.cnblogs.com/rinck/p/18251788

相关文章

  • 微信同声传译小程序插件使用教程
    微信同声传译小程序插件——机器翻译、智能语音案例可搜索“一起学英语鸭”小程序查看, 实现效果如下图:插件功能语音转文字语音合成文本翻译 step1:添加插件在使用前,需要登录官网设置→第三方服务→添加插件搜索【微信同声传译】并添加在需要使......
  • 微信阅读网站小程序(30029)
     有需要的同学,源代码和配套文档领取,加文章最下方的名片哦一、项目演示项目演示视频二、资料介绍完整源代码(前后端源代码+SQL脚本)配套文档(LW+PPT+开题报告)远程调试控屏包运行三、技术介绍Java语言SSM框架SpringBoot框架Vue框架JSP页面Mysql数据库IDEA/Eclipse开发四、项......
  • WPF customized Image control can add watermark , save and restore
     //usercontrol//xaml<UserControlx:Class="WpfApp173.ImageZoomPanWatermark"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml&quo......
  • 209. Minimum Size Subarray Sum
    Givenanarrayofpositiveintegersnumsandapositiveintegertarget,returntheminimallengthofasubarraywhosesumisgreaterthanorequaltotarget.Ifthereisnosuchsubarray,return0instead.Example1:Input:target=7,nums=[2,3,1,2,......
  • 【工具推荐】基于Win10系统自带软件Xbox Game Bar录屏后下载安装ffmpeg然后使用ffmpeg
    本文详细介绍了如何基于Win10系统自带软件XboxGameBar录屏,以及如何下载安装ffmpeg,然后如何使用ffmpeg将录屏得到的mp4视频转换为可用于博客中做功能演示用的gif动态图片,同时还提供了一个一键转换脚本,减少繁琐的操作步骤。......
  • 【计算机毕业设计】240基于微信小程序的校园综合服务平台
    ......
  • 【计算机毕业设计】241外卖微信小程序
    ......
  • Dynamsoft.DotNet.BarcodeReader.Bundle-10.2.1100
    DynamsoftBarcodeReaderSDK.NetEditionDynamsoftBarcodeReaderSDKenablesyoutoefficientlyembedbarcodereadingfunctionalityinyourweb,desktopormobileapplicationusingjustafewlinesofcode.Savingyoumonthsofaddeddevelopmenttime......
  • 不同PC设备共用同用一套键鼠,以及使用Barrier常见问题解决方案
    设备环境:一台windows11,一台ubuntu桌面版网络环境:使用同一wifi一、下载安装windows安装下载地址:Releasev2.4.0·debauchee/barrier·GitHububuntu安装sudoapt-getinstallbarrier二、设置使用服务端设置服务端作为主控端,键鼠连接的是服务端设备,配置连接......
  • 微信小程序
    环境搭建官网地址https://mp.weixin.qq.com/游客登录,本地开发没问题,发布和支付等功能无法使用。注册小程序账号,后期发布代码等需要使用。个人版小程序企业版小程序(建议)目录文件├──pages 【页面文件目录】│  ├──index 【页面】│  │  ......