navbar-item.vue 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <!-- 顶部导航栏 - 单元格 -->
  2. <template>
  3. <view class="ss-flex ss-col-center">
  4. <!-- 类型一: 文字 -->
  5. <view
  6. v-if="data.type === 'text'"
  7. class="nav-title inline"
  8. :style="[{ color: data.textColor, width: width }]"
  9. >
  10. {{ data.text }}
  11. </view>
  12. <!-- 类型二: 图片 -->
  13. <view
  14. v-if="data.type === 'image'"
  15. :style="[{ width: width }]"
  16. class="menu-icon-wrap ss-flex ss-row-center ss-col-center"
  17. @tap="sheep.$router.go(data.url)"
  18. >
  19. <image class="nav-image" :src="sheep.$url.cdn(data.imgUrl)" mode="aspectFit"></image>
  20. </view>
  21. <!-- 类型三: 搜索框 -->
  22. <view class="ss-flex-1" v-if="data.type === 'search'" :style="[{ width: width }]">
  23. <s-search-block
  24. :placeholder="data.placeholder || '搜索关键字'"
  25. :radius="data.borderRadius"
  26. elBackground="#fff"
  27. :height="height"
  28. :width="width"
  29. @click="sheep.$router.go('/pages/index/search')"
  30. ></s-search-block>
  31. </view>
  32. </view>
  33. </template>
  34. <script setup>
  35. import sheep from '@/sheep';
  36. import { computed } from 'vue';
  37. // 接收参数
  38. const props = defineProps({
  39. data: {
  40. type: Object,
  41. default: () => ({}),
  42. },
  43. width: {
  44. type: String,
  45. default: '1px',
  46. },
  47. });
  48. const height = computed(() => sheep.$platform.capsule.height);
  49. </script>
  50. <style lang="scss" scoped>
  51. .nav-title {
  52. font-size: 36rpx;
  53. color: #333;
  54. text-align: center;
  55. }
  56. .menu-icon-wrap {
  57. .nav-image {
  58. height: 24px;
  59. }
  60. }
  61. </style>