MyTabbar.vue 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <template>
  2. <view class="tabbar">
  3. <view @click="switchTab(0)" class="tabbar-item">
  4. <image class="tabbar-icon" :src="actived===0?tabbarList[0].selectedIconPath:tabbarList[0].iconPath"
  5. mode="aspectFit"></image>
  6. <text class="noselect-text">{{tabbarList[0].text}}</text>
  7. </view>
  8. <view @click="switchTab(1)" class="tabbar-item">
  9. <view class="tabbar-item1">
  10. <image class="tabbar-icon1" :src="tabbarList[1].iconPath" mode="aspectFit"></image>
  11. </view>
  12. </view>
  13. <view @click="switchTab(2)" class="tabbar-item">
  14. <image class="tabbar-icon" :src="actived===2?tabbarList[2].selectedIconPath:tabbarList[2].iconPath"
  15. mode="aspectFit"></image>
  16. <text class="noselect-text">{{tabbarList[2].text}}</text>
  17. </view>
  18. </view>
  19. </template>
  20. <script>
  21. export default {
  22. name: 'MyTabBar',
  23. props: ['actived'],
  24. data() {
  25. return {
  26. tabbarList: [{
  27. iconPath: '../static/tabbar/home.png',
  28. selectedIconPath: "../static/tabbar/selectedHome.png",
  29. text: '首页'
  30. },
  31. {
  32. iconPath: '../static/tabbar/one.png',
  33. text: ''
  34. },
  35. {
  36. iconPath: '../static/tabbar/my.png',
  37. selectedIconPath: "../static/tabbar/selectedMy.png",
  38. text: '我的'
  39. },
  40. ]
  41. }
  42. },
  43. methods: {
  44. switchTab(index) {
  45. this.$emit('tab-switch', index);
  46. },
  47. }
  48. }
  49. </script>
  50. <style scoped>
  51. .tabbar {
  52. display: flex;
  53. border-top: 1px solid #ccc;
  54. background-color: #fff;
  55. position: fixed;
  56. bottom: 0;
  57. left: 0;
  58. width: 100%;
  59. z-index: 99;
  60. padding-top:8rpx ;
  61. height: 120rpx;
  62. }
  63. .tabbar-item {
  64. flex: 1;
  65. display: flex;
  66. flex-direction: column;
  67. align-items: center;
  68. justify-content: center;
  69. height: 50px;
  70. position: relative;
  71. }
  72. .tabbar-icon {
  73. width: 48rpx;
  74. height: 46rpx;
  75. margin-bottom: 10rpx;
  76. }
  77. .tabbar-text-actived{
  78. font-size: 12rpx;
  79. color: #feebd7;
  80. }
  81. .tabbar-icon1 {
  82. display: inline-block;
  83. width: 120rpx;
  84. height: 120rpx;
  85. position: fixed;
  86. bottom: 36rpx;
  87. left: 320rpx
  88. }
  89. .noselect-text{
  90. color:#333
  91. }
  92. </style>