hBomTab.vue 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <template>
  2. <!--底部tab 切换-->
  3. <view class="hBomTab w-100 bgc-white posi-absolute posi-fixed-bottom border-gray-top flew flew-around">
  4. <div class="item " v-for="(item,index) in tab_list" :key="index" :style="{color:color}">
  5. <div class="name font-size20 flew-column flew flew-align-center "
  6. @tap = "tabChange(index)"
  7. :style="{color:index === tab_index ? theme:''}"
  8. >
  9. <image class="img" v-if="index === tab_index && item.value !== '2'" :src="h_global.getImgPath(item.icon[1])">
  10. </image>
  11. <image class="img" v-else-if="index !== tab_index && item.value !== '2'" :src="h_global.getImgPath(item.icon[0])"></image>
  12. <image class="img2" v-else :src="h_global.getImgPath(item.icon[0])"></image>
  13. <div style="font-size: 22rpx;">
  14. {{item.name ? item.name : '' }}
  15. </div>
  16. </div>
  17. </div>
  18. </view>
  19. </template>
  20. <script>
  21. export default {
  22. name: "hBomTab.vue",
  23. data() {
  24. return {
  25. // a:1,
  26. tab_index: -1,
  27. }
  28. },
  29. props:{
  30. curr_tab_index:{
  31. default:1
  32. },
  33. theme:{
  34. default:'#4D4D4D'
  35. },
  36. color:{
  37. default:'#4D4D4D'
  38. },
  39. tab_list:{
  40. default(){
  41. return []
  42. },
  43. type:Array
  44. }
  45. },
  46. methods: {
  47. tabChange(index){
  48. this.tab_index = index; //这种赋值很奇怪 不能直接
  49. let tab_one = this.tab_list[index];
  50. this.$emit('tabChange',{index,tab_one})
  51. }
  52. },
  53. mounted(){
  54. this.tab_index = this.curr_tab_index;
  55. // console.log( 'curr_tab_index',this.curr_tab_index)
  56. // console.log( this.tab_list)
  57. }
  58. }
  59. </script>
  60. <style scoped lang="scss">
  61. .item{
  62. margin: 20upx;
  63. height: auto;
  64. color: #4D4D4D;
  65. flex-grow: 1;
  66. .img{
  67. width: 50upx;
  68. height: 50upx;
  69. }
  70. .img2{
  71. width: 120rpx;
  72. height: 120rpx;
  73. position: absolute;
  74. bottom: 30rpx;
  75. }
  76. }
  77. </style>