答案:

  1. <div class="height">
  2. <div :style="height='height+px'"> 胶囊栏高度 <div />
  3. <div />
  4. <script>
  5. // #ifdef MP-WEIXIN
  6. let menuHeight = uni.getMenuButtonBoundingClientRect().height
  7. this.menuHeight = menuHeight
  8. // #endif
  9. </script>
  10. <style >
  11. .height{
  12. height: var(--status-bar-height); // 此为顶部到胶囊栏高度
  13. }
  14. <style />