nav-bar.vue 2.1 KB

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