t-tabbar.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <template>
  2. <view class="tab_bar">
  3. <view class="tabbarBox">
  4. <view class="handleBox" v-for="(item,index) in tabBarList" :key="index">
  5. <view class="menuBox" @click="goPages(item.pageIndex)">
  6. <view class="menuIcon">
  7. <image v-if="item.indexName!=selectIndex" class="img" :src="item.iconPath"></image>
  8. <image v-else class="img" :src="item.selectIconPath"></image>
  9. </view>
  10. <view class="menuName">
  11. <text class="Text">{{item.tabbarName}}</text>
  12. </view>
  13. </view>
  14. </view>
  15. </view>
  16. </view>
  17. </template>
  18. <script>
  19. export default {
  20. props: {
  21. page: {
  22. type: String,
  23. default: "homeIndex"
  24. }
  25. },
  26. watch: {
  27. page: {
  28. handler(value) {
  29. this.selectIndex = value;
  30. },
  31. immediate: true,
  32. deep: true
  33. }
  34. },
  35. data() {
  36. return {
  37. selectIndex: "",
  38. tabBarList: [{
  39. "flag": 'icon',
  40. "pageIndex": "pages/tabbar/homePage",
  41. "iconPath": "/static/menu_imgs/home.png",
  42. "selectIconPath": "/static/menu_imgs/home-default.png",
  43. "tabbarName": "首页"
  44. },
  45. {
  46. "flag": 'icon',
  47. "pageIndex": "pages/tabbar/workBranch",
  48. "iconPath": "/static/menu_imgs/home.png",
  49. "selectIconPath": "/static/menu_imgs/home-default.png",
  50. "tabbarName": "工作台"
  51. },
  52. {
  53. "flag": 'icon',
  54. "pageIndex": "pages/tabbar/personCenter",
  55. "iconPath": "/static/menu_imgs/home.png",
  56. "selectIconPath": "/static/menu_imgs/home-default.png",
  57. "tabbarName": "个人中心"
  58. }
  59. ]
  60. }
  61. },
  62. //uniapp子组件不支持应用生命周期,所以只能用vue生命周期
  63. mounted() {
  64. },
  65. methods: {
  66. //进入tabble页
  67. goPages(pageIndex) {
  68. uni.switchTab({
  69. url: pageIndex
  70. })
  71. },
  72. },
  73. }
  74. </script>
  75. <style lang="scss">
  76. .tab_bar {
  77. width: 100vw;
  78. height: 150rpx;
  79. position: fixed;
  80. bottom: 0rpx;
  81. background: #ffffff;
  82. .tabbarBox {
  83. display: flex;
  84. margin-top: 5rpx;
  85. justify-content: space-evenly;
  86. .handleBox {
  87. width: 20vw;
  88. height: 120rpx;
  89. .menuBox {
  90. padding: 0rpx 20rpx;
  91. width: 120rpx;
  92. height: 98%;
  93. text-align: center;
  94. .img {
  95. width: 50rpx;
  96. height: 50rpx;
  97. }
  98. }
  99. }
  100. }
  101. }
  102. .Text {
  103. font-size: 25rpx;
  104. }
  105. </style>