nav-bar.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <view class="im-nav-bar">
  3. <!-- #ifndef H5 -->
  4. <view style="height: var(--status-bar-height)"></view>
  5. <!-- #endif -->
  6. <view class="im-nav-bar-content">
  7. <view class="back" @click="handleBackClick" v-if="back">
  8. <uni-icons type="back" :size="iconFontSize"></uni-icons>
  9. </view>
  10. <view class="title" v-if="title">
  11. <slot></slot>
  12. </view>
  13. <view class="btn">
  14. <uni-icons class="btn-item" v-if="search" type="search" :size="iconFontSize"
  15. @click="$emit('search')"></uni-icons>
  16. <uni-icons class="btn-item" v-if="add" type="plusempty" :size="iconFontSize" @click="$emit('add')"></uni-icons>
  17. <uni-icons class="btn-item" v-if="more" type="more-filled" :size="iconFontSize"
  18. @click="$emit('more')"></uni-icons>
  19. </view>
  20. </view>
  21. </view>
  22. </template>
  23. <script>
  24. export default {
  25. name: "nav-bar",
  26. props: {
  27. back: {
  28. type: Boolean,
  29. default: false
  30. },
  31. title: {
  32. type: Boolean,
  33. default: true
  34. },
  35. search: {
  36. type: Boolean,
  37. default: false
  38. },
  39. add: {
  40. type: Boolean,
  41. default: false
  42. },
  43. more: {
  44. type: Boolean,
  45. default: false
  46. },
  47. iconFontSize: {
  48. type: Number,
  49. default: 24
  50. }
  51. },
  52. data() {
  53. return {}
  54. },
  55. computed: {
  56. height() {
  57. }
  58. },
  59. methods: {
  60. handleBackClick() {
  61. uni.navigateBack({
  62. delta: 1
  63. })
  64. }
  65. }
  66. }
  67. </script>
  68. <style scoped lang="scss">
  69. .im-nav-bar {
  70. background-color: #fff;
  71. //background-color: $im-bg;
  72. position: fixed;
  73. top: 0;
  74. width: 100%;
  75. color: $im-text-color;
  76. border-bottom: 1px solid $im-border-light;
  77. font-size: $im-font-size-large;
  78. z-index: 99;
  79. .im-nav-bar-content {
  80. display: flex;
  81. align-items: center;
  82. justify-content: center;
  83. box-sizing: border-box;
  84. height: $im-nav-bar-height;
  85. .title {}
  86. .back {
  87. position: absolute;
  88. left: 0;
  89. height: 100%;
  90. display: flex;
  91. align-items: center;
  92. padding: 12px;
  93. font-size: 22px;
  94. box-sizing: border-box;
  95. }
  96. .btn {
  97. position: absolute;
  98. right: 0;
  99. height: 100%;
  100. display: flex;
  101. padding: 12px;
  102. align-items: center;
  103. box-sizing: border-box;
  104. .btn-item {
  105. margin-left: 8px;
  106. }
  107. }
  108. }
  109. }
  110. </style>