index.vue 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <template>
  2. <view class="tab-bar">
  3. <view class="content">
  4. <view class="one-tab" v-for="(item, index) in tabBarList" :key="index" @click="selectTabBar(item.pagePath)">
  5. <view class="tabItem">
  6. <view class="tabItem_c" v-if="routePath === item.pagePath">
  7. </view>
  8. <view>
  9. <view class="tab-img">
  10. <image v-if="routePath === item.pagePath" class="img"
  11. :class="[item.selectedIconPath=='../../static/tabbar/index_a.png'?'aw':'']"
  12. :src="item.selectedIconPath" mode="widthFix">
  13. </image>
  14. <image v-else class="img" :src="item.iconPath"></image>
  15. </view>
  16. </view>
  17. <view v-if="routePath === item.pagePath" class="tit selectTexts">{{ item.text }}</view>
  18. <view v-else class="tit texts">{{ item.text }}</view>
  19. </view>
  20. </view>
  21. </view>
  22. </view>
  23. </template>
  24. <script>
  25. export default {
  26. props: {
  27. // 底部导航栏数据
  28. tabBarList: {
  29. type: Array,
  30. required: true
  31. },
  32. // 当前页面路径
  33. routePath: {
  34. type: String,
  35. required: true
  36. }
  37. },
  38. data() {
  39. return {};
  40. },
  41. methods: {
  42. selectTabBar(path) {
  43. this.$emit('onTabBar', path)
  44. }
  45. },
  46. created() {
  47. console.log('tabBarList----', this.tabBarList);
  48. console.log('routePath---', this.routePath);
  49. }
  50. };
  51. </script>
  52. <style lang="scss" scoped>
  53. @import "./index.scss";
  54. </style>