navbar-line.vue 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <template>
  2. <view>
  3. <view class="cu-custom" :style="[{height:CustomBar + 'px'},{position: !hasPlacer ? 'absolute':'relative'}]">
  4. <view class="cu-bar" :style="{background:bgColor,height: CustomBar + 'px',paddingTop: StatusBar + 'px'}">
  5. <view class="bar-wrap">
  6. <slot />
  7. </view>
  8. </view>
  9. </view>
  10. </view>
  11. </template>
  12. <script>
  13. export default {
  14. data() {
  15. return {
  16. StatusBar: this.StatusBar,
  17. CustomBar: this.CustomBar
  18. };
  19. },
  20. name: 'cu-custom',
  21. props: {
  22. bgColor: {
  23. type: String,
  24. default: '#ffffff'
  25. },
  26. //默认设置relative
  27. hasPlacer:{
  28. type: Boolean,
  29. default: true
  30. }
  31. },
  32. computed:{
  33. },
  34. methods: {
  35. }
  36. }
  37. </script>
  38. <style scoped>
  39. .cu-custom {
  40. display: block;
  41. position: relative;
  42. }
  43. .cu-bar {
  44. display: flex;
  45. position: fixed;
  46. width: 100%;
  47. top: 0;
  48. left: 0;
  49. right: 0;
  50. z-index: 1024;
  51. transition: background 1s linear;
  52. /* box-shadow: 0 1rpx 6rpx rgba(0, 0, 0, 0.1); */
  53. }
  54. .bar-wrap{
  55. position: relative;
  56. width: 100%;
  57. }
  58. </style>