navBar.vue 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <template>
  2. <view>
  3. <!--图标入口-->
  4. <view class="diy-navbar" :style="{background:itemData.style.background}">
  5. <view class="item" v-for="(item, index) in itemData.data" :key="index" :style="'width:'+item_width+';'" @click="gotoDetail(item)">
  6. <image :src="item.imgUrl" mode="widthFix"></image>
  7. <text class="gray3" :style="{color:item.color}">{{item.text}}</text>
  8. </view>
  9. </view>
  10. </view>
  11. </template>
  12. <script>
  13. export default {
  14. data() {
  15. return {
  16. //单个宽度
  17. item_width: '25%'
  18. }
  19. },
  20. props: ['itemData'],
  21. created() {
  22. this.item_width = 100 / Math.abs(this.itemData.style.rowsNum) + '%';
  23. },
  24. methods: {
  25. /*跳转页面*/
  26. gotoDetail(e) {
  27. this.gotoPage(e.linkUrl);
  28. }
  29. }
  30. }
  31. </script>
  32. <style>
  33. .diy-navbar {
  34. margin: 20rpx;
  35. padding: 20rpx 0;
  36. border-radius: 12rpx;
  37. background: #FFFFFF;
  38. display: flex;
  39. justify-content: flex-start;
  40. flex-wrap: wrap;
  41. }
  42. .diy-navbar .item {
  43. display: flex;
  44. flex-direction: column;
  45. justify-content: center;
  46. align-items: center;
  47. margin-top: 20rpx;
  48. width: 120rpx;
  49. height: 140rpx;
  50. }
  51. .diy-navbar .item image {
  52. width: 70rpx;
  53. height: 70rpx;
  54. }
  55. .diy-navbar .item text {
  56. display: block;
  57. text-overflow: ellipsis;
  58. white-space: nowrap;
  59. width: 100%;
  60. overflow: hidden;
  61. line-height: 66rpx;
  62. font-size: 26rpx;
  63. text-align: center;
  64. }
  65. </style>