nav-bar.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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: $im-bg-linear;
  74. position: fixed;
  75. top: 0;
  76. width: 100%;
  77. color: $im-text-color;
  78. border-bottom: 1px solid $im-border-light;
  79. font-size: $im-font-size-large;
  80. z-index: 99;
  81. .im-nav-bar-content {
  82. display: flex;
  83. align-items: center;
  84. justify-content: center;
  85. box-sizing: border-box;
  86. height: $im-nav-bar-height;
  87. .title {}
  88. .back {
  89. position: absolute;
  90. left: 0;
  91. height: 100%;
  92. display: flex;
  93. align-items: center;
  94. padding: 12px;
  95. font-size: 22px;
  96. box-sizing: border-box;
  97. }
  98. .btn {
  99. position: absolute;
  100. right: 0;
  101. height: 100%;
  102. display: flex;
  103. padding: 12px;
  104. align-items: center;
  105. box-sizing: border-box;
  106. .btn-item {
  107. margin-left: 8px;
  108. }
  109. }
  110. }
  111. }
  112. </style>