tabBar.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <template>
  2. <view class="tabBarBox">
  3. <view class="tabBarItem" v-for="(item, index) in lists" :key="index" @click="clickHandle(item, index)">
  4. <image :src="(currentIndex === index) ? item['selectedIconPath'] : item['iconPath']"></image>
  5. <text :style="{'color': (currentIndex === index) ? item['selectedColor'] : item['color']}">{{item['name']}}</text>
  6. </view>
  7. </view>
  8. </template>
  9. <script>
  10. export default {
  11. name:"tabBar",
  12. data() {
  13. return {
  14. lists: [
  15. {
  16. name: '待签收',
  17. iconPath: '/static/images/received.png',
  18. selectedIconPath: '/static/images/received_selected.png',
  19. color: '#A6AAB2',
  20. selectedColor: '#6495F0',
  21. component: 'received'
  22. },
  23. {
  24. name: '待核查',
  25. iconPath: '/static/images/nocheck.png',
  26. selectedIconPath: '/static/images/nocheck_selected.png',
  27. color: '#A6AAB2',
  28. selectedColor: '#6495F0',
  29. component: 'nocheck'
  30. },
  31. {
  32. name: '已核查',
  33. iconPath: '/static/images/checked.png',
  34. selectedIconPath: '/static/images/checked_selected.png',
  35. color: '#A6AAB2',
  36. selectedColor: '#6495F0',
  37. component: 'checked'
  38. },
  39. {
  40. name: '我的',
  41. iconPath: '/static/images/me.png',
  42. selectedIconPath: '/static/images/me_selected.png',
  43. color: '#A6AAB2',
  44. selectedColor: '#6495F0',
  45. component: 'me'
  46. },
  47. ]
  48. };
  49. },
  50. props: {
  51. currentIndex: {
  52. type: Number,
  53. default: 0
  54. }
  55. },
  56. methods: {
  57. clickHandle(item, index){
  58. this.$emit('tabClick', item)
  59. uni.$emit('setIndexEvent', index)
  60. }
  61. }
  62. }
  63. </script>
  64. <style lang="scss">
  65. .tabBarBox {
  66. height: $tabbar-height;
  67. display: flex;
  68. text-align: center;
  69. align-items: center;
  70. >view {
  71. flex: 1;
  72. display: flex;
  73. flex-direction: column;
  74. text-align: center;
  75. align-items: center;
  76. >text {
  77. margin-top: 2px;
  78. font-size: 12px;
  79. }
  80. >image {
  81. width: 24px;
  82. height: 24px;
  83. }
  84. }
  85. }
  86. </style>