custom-nav.vue 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <template>
  2. <view>
  3. <view class="nav" :style="{ height: navBarHeight + 'px' }">
  4. <view class="nav-main" :style="{ background: bgColor ? bgColor : '' }">
  5. <view
  6. class="capsule-box"
  7. :style="{ height: menuHeight + 'px', 'min-height': menuHeight + 'px', 'line-height': menuHeight + 'px', bottom: menuBotton + 'px', left: menuRight + 'px' }"
  8. >
  9. <slot></slot>
  10. </view>
  11. </view>
  12. </view>
  13. </view>
  14. </template>
  15. <script>
  16. let app = getApp();
  17. export default {
  18. props: ['bgColor'],
  19. data() {
  20. return {
  21. navBarHeight: app.globalData.navBarHeight, //导航栏高度
  22. menuRight: app.globalData.menuRight, // 胶囊距右方间距(方保持左、右间距一致)
  23. menuBotton: app.globalData.menuBotton,
  24. menuHeight: app.globalData.menuHeight
  25. };
  26. },
  27. methods: {}
  28. };
  29. </script>
  30. <style lang="scss">
  31. .nav {
  32. position: fixed;
  33. top: 0;
  34. left: 0;
  35. width: 100vw;
  36. }
  37. .nav-main {
  38. width: 100%;
  39. height: 100%;
  40. // height:44rpx;
  41. position: relative;
  42. }
  43. .nav .capsule-box {
  44. position: absolute;
  45. box-sizing: border-box;
  46. width: 100%;
  47. }
  48. </style>