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

自定义Taro的navBar的宽度和高度

本方法是计算自定义navbar的宽度和高度,输出的参数有
navBarHeight, menuBottom,menuHeight, menuRectWidth,windowWidth, windowHeight,具体代码如下:

export function getCustomNavBarRect():| {navBarHeight: number;menuBottom: number;menuHeight: number;menuRectWidth: number;windowWidth: number;windowHeight: number;}| undefined {const { statusBarHeight = 0, screenWidth, windowWidth, windowHeight } = Taro.getSystemInfoSync();const menuButtonInfo = Taro.getMenuButtonBoundingClientRect();const navBarHeight =(menuButtonInfo.top - statusBarHeight) * 2 + menuButtonInfo.height + statusBarHeight; // 导航栏高度const menuBottom = menuButtonInfo.top - statusBarHeight; // 胶囊距底部间距(顶部间距也是这个)const menuHeight = menuButtonInfo.height; // 胶囊高度const menuRectWidth = screenWidth - menuButtonInfo.left; // 胶囊宽度(包括距离屏幕右侧的距离)const barRect = {navBarHeight,menuBottom,menuHeight,menuRectWidth,windowWidth,windowHeight,};if (Taro.getStorageSync('customNavBarRect')) return Taro.getStorageSync('customNavBarRect');Taro.setStorageSync('customNavBarRect', barRect);return barRect;
}
http://www.lryc.cn/news/133557.html

相关文章:

  • 用Python编程实现百度自然语言处理接口的对接,助力你开发智能化处理程序
  • 系统架构设计专业技能 · 系统工程与系统性能
  • 初识网络原理(笔记)
  • 嵌入式C语言基本操作方法之经典
  • postgresql \watch实用的使用方法
  • Cocos2d 项目问题记录
  • 系统架构合理性的思考 | 京东云技术团队
  • Amelia预订插件:WordPress企业级预约系统
  • 共享门店模式:线下门店的商家如何利用它增加客户
  • 实现矩阵地图与rviz地图重合
  • 设计模式十九:备忘录模式(Memento Pattern)
  • 【题解】二叉搜索树与双向链表
  • 【真实案例】解决后端接口调用偶尔超时问题
  • 操作符详解(1)
  • <指针进阶>指针数组和数组指针傻傻分不清?
  • 无代码集成飞书连接更多应用
  • 三分钟解决AE缓存预览渲染错误、暂停、卡顿问题
  • 朴实无华的数据增强然后训练一下应用在电网异物检测领域,好像有自己的数据集就能发文了
  • 【使用教程】在Ubuntu下运行CANopen通信PMM伺服电机使用教程(NimServoSDK_V2.0.0)
  • vue3+ts+vite项目页面初始化loading加载效果
  • ElasticSearch 数据聚合、自动补全(自定义分词器)、数据同步
  • 神经网络基础-神经网络补充概念-18-多个样本的向量化
  • *看门狗1
  • nginx防盗链
  • 8月16日上课内容 第二章 部署LVS-DR群集
  • ViT模型架构和CNN区别
  • 发布python模仿2023年全国职业的移动应用开发赛项样式开发的开源的新闻api,以及安卓接入案例代码
  • adb command
  • 在ARM服务器上一键安装Proxmox VE(以在Oracle Cloud VPS上为例)(甲骨文)
  • KMP算法(JS)