代码碎片
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>
