【uni-app】对齐胶囊容器组件

代码碎片

html 复制代码
<template>
  <div>
    <view :style="{ height: `${statusBarHeight}px` }"></view>
    <view
      class=""
      :style="{
        height: `${menuButtonHeight + menuButtonPadding * 2}px`,
        width: `${menuButtonInfo.left}px`,
      }"
    >
      <slot name="left"></slot>
      <slot name="mid"></slot>
    </view>
  </div>
</template>

<script lang="ts" setup>
const menuButtonInfo = uni.getMenuButtonBoundingClientRect() // 胶囊按钮信息
const statusBarHeight = uni.getSystemInfoSync().statusBarHeight // 系统信息里的状态栏高度

console.log('menuButtonInfo', menuButtonInfo)
console.log('statusBarHeight', statusBarHeight)
const menuButtonPadding = menuButtonInfo.top - statusBarHeight
const menuButtonHeight = menuButtonInfo.height
</script>

<style lang="scss" scoped>
//
</style>
相关推荐
拖拉斯旋风3 分钟前
深入浅出 RAG:从网页爬取到智能问答的完整链路解析
前端
Mintopia17 分钟前
Vite 发展现状与回顾:从“极致开发体验”到生态基础设施
前端
前端双越老师40 分钟前
前端面试常见的 10 个场景题
前端·面试·求职
孟祥_成都1 小时前
【全网最通俗!新手到AI全栈开发必读】 AI 是如何进化到大模型的
前端·人工智能·全栈
牛奶2 小时前
AI辅助开发的基础概念
前端·人工智能·ai编程
摸鱼的春哥2 小时前
Agent教程15:认识LangChain,Agent框架的王(上)
前端·javascript·后端
明月_清风3 小时前
自定义右键菜单:在项目里实现“选中文字即刻生成新提示”
前端·javascript
明月_清风3 小时前
告别后端转换:高质量批量导出实战
前端·javascript
刘发财7 小时前
弃用html2pdf.js,这个html转pdf方案能力是它的几十倍
前端·javascript·github
牛奶10 小时前
2026年大模型怎么选?前端人实用对比
前端·人工智能·ai编程